3

我的本地 JBoss 的 MySQL 模块有一些问题。

在 $JBOSS_HOME 我创建了 com/mysql/main 那里,我删除了 mysql-connector-java-5.1.26-bin.jar 和 module.xml

模块.xml

然后我配置了我的数据源。

Standalone.xml 中的数据源配置

在 Netbeans 项目中,persistence.xml 通过 Persistence Unit 向导配置为附加,Netbeans 自动识别配置的数据源,这很酷。

持久性.xml

现在的问题是,当我想“从数据库创建实体类”时,我收到了这个错误。

在此处输入图像描述

我已经检查了整个网络。我想我有一个很好的配置,但这个错误仍然存​​在。

网豆:7.3.1;Mysql 连接器:5.1.26;应用服务器:JBoss EAP 6.1.0;mysql:5.6.14;Windows 7的; 爪哇 7

好心提醒。谢谢。

4

2 回答 2

0

今天找到答案了

只需设置driver-class和driver同名com.mysql.jdbc.Driver

<driver-class>com.mysql.jdbc.Driver</driver-class>
    <driver>com.mysql.jdbc.Driver</driver>
    <pool>
        <min-pool-size>10</min-pool-size>
        <max-pool-size>100</max-pool-size>
        <use-strict-min>true</use-strict-min>
        <flush-strategy>IdleConnections</flush-strategy>
    </pool>
    <security>
        <user-name>root</user-name>
        <password>root</password>
    </security>

并创建 jboss-ds xml 文件并将其放入 -ejb\src\main\setup

<?xml version="1.0" encoding="UTF-8"?>
<datasources>    
    <datasource jta="false" jndi-name="java:/MysqlDS" pool-name="MysqlDS" enabled="true" use-ccm="false" statistics-enabled="false">
        <connection-url>jdbc:mysql://localhost:3306/dmbs?zeroDateTimeBehavior=convertToNull&amp;amp;useUnicode=yes&amp;amp;characterEncoding=UTF-8</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <driver>com.mysql.jdbc.Driver</driver>
        <pool>
            <min-pool-size>10</min-pool-size>
            <max-pool-size>100</max-pool-size>
            <use-strict-min>true</use-strict-min>
            <flush-strategy>IdleConnections</flush-strategy>
        </pool>
        <security>
            <user-name>root</user-name>
            <password>root</password>
        </security>
        <validation>
            <validate-on-match>false</validate-on-match>
            <background-validation>false</background-validation>
        </validation>
        <timeout>
            <set-tx-query-timeout>false</set-tx-query-timeout>
            <blocking-timeout-millis>0</blocking-timeout-millis>
            <idle-timeout-minutes>3</idle-timeout-minutes>
            <query-timeout>0</query-timeout>
            <use-try-lock>0</use-try-lock>
            <allocation-retry>0</allocation-retry>
            <allocation-retry-wait-millis>0</allocation-retry-wait-millis>
        </timeout>
        <statement>
            <track-statements>true</track-statements>
            <share-prepared-statements>false</share-prepared-statements>
        </statement>    
    </datasource>      
</datasources>

和我的standalone.xml 配置

<datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jta="false" jndi-name="java:/MysqlDS" pool-name="MysqlDS" enabled="true" use-ccm="false" statistics-enabled="false">
                    <connection-url>jdbc:mysql://localhost:3306/dmbs?zeroDateTimeBehavior=convertToNull&amp;amp;useUnicode=yes&amp;amp;characterEncoding=UTF-8</connection-url>
                    <driver-class>com.mysql.jdbc.Driver</driver-class>
                    <driver>com.mysql.jdbc.Driver</driver>
                    <pool>
                        <min-pool-size>10</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                        <use-strict-min>true</use-strict-min>
                        <flush-strategy>IdleConnections</flush-strategy>
                    </pool>
                    <security>
                        <user-name>root</user-name>
                        <password>root</password>
                    </security>
                    <validation>
                        <validate-on-match>false</validate-on-match>
                        <background-validation>false</background-validation>
                    </validation>
                    <timeout>
                        <set-tx-query-timeout>false</set-tx-query-timeout>
                        <blocking-timeout-millis>0</blocking-timeout-millis>
                        <idle-timeout-minutes>3</idle-timeout-minutes>
                        <query-timeout>0</query-timeout>
                        <use-try-lock>0</use-try-lock>
                        <allocation-retry>0</allocation-retry>
                        <allocation-retry-wait-millis>0</allocation-retry-wait-millis>
                    </timeout>
                    <statement>
                        <track-statements>true</track-statements>
                        <share-prepared-statements>false</share-prepared-statements>
                    </statement>
                </datasource>
                <drivers>
                    <driver name="com.mysql.jdbc.Driver" module="com.mysql.jdbc">
                      <driver-class>com.mysql.jdbc.Driver</driver-class>
                      <!--  <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>-->
                    </driver>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>

我在 C:\wildfly-9.0.0\modules\system\layers\base\com\mysql\jdbc\main 和 mysql 驱动程序 jar 附近的 module.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql.jdbc">
        <resources>
            <resource-root path="mysql-connector-java-5.1.32-bin.jar"/>
        </resources>
        <dependencies>
            <module name="javax.api"/>
            <module name="javax.transaction.api"/>
</dependencies>
</module>
于 2014-09-24T13:29:36.103 回答
0

在 $JBOSS_HOME 我创建了 com/mysql/main 那里,我删除了 mysql-connector-java-5.1.26-bin.jar 和 module.xml

您能否确保该文件夹位于 $JBOSS_HOME/modules 位置下

于 2013-11-03T17:01:19.847 回答