阅读Internet上的数字帖子后,我在JBoss AS 7安装中执行了以下操作:
在... / modules / com / mysql / main中添加了一个新模块:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.47.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.resource.api"/>
</dependencies>
</module>
在standalone.xml中创建了新的数据源:
<datasource jta="false" jndi-name="java:jboss/env/jdbc/Mysql_PRPPG" pool-name="env/jdbc/Mysql_PRPPG" enabled="true" use-ccm="true">
<connection-url>jdbc:mysql:200.17.247.200:3306/xxx</connection-url>
<driver>mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>20</min-pool-size>
<max-pool-size>100</max-pool-size>
</pool>
<security>
<user-name>discentes</user-name>
<password>discentes@$*2018</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
在standalone.xml中添加了新的驱动程序:
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
JBoss可以正常启动,但是当我打开控制台页面并执行连接测试时,出现异常:
Caused by: javax.resource.ResourceException: Wrong driver class [class com.mysql.jdbc.Driver] for this connection URL [jdbc:mysql:200.17.247.200:3306/discentes-ppg]
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:256) [ironjacamar-jdbc-1.0.12.Final.jar:1.0.12.Final]
... 41 more
怎么了?
答案 0 :(得分:0)
您可以尝试对MS SQL Server JDBC连接使用以下语法:
jdbc:sqlserver://<host>:<port>;<propertyName>=<propertyValue>
答案 1 :(得分:0)
经过一夜的睡眠,一杯美味的早晨咖啡以及对我所有工作的评价,我发现那条线
<connection-url>jdbc:mysql:200.17.247.200:3306/xxx</connection-url>
实际上应该是
<connection-url>jdbc:mysql://200.17.247.200:3306/xxx</connection-url>
因此,在IP地址之前缺少“ //”阻止了建立连接。