2

我在 Wildfly 10 中使用 sqljdbc4.jar 时遇到了大问题。当我启动服务器时,出现以下问题:

Unable to instantiate driver class "com.microsoft.sqlserver.jdbc.SQLServerDataSource" 

......还有几个例外......

08:32:12,570 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.subunit."PPJAS.ear"."WebService.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."PPJAS.ear"."WebService.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of subdeployment "WebService.war" of deployment "PPJAS.ear"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

我到目前为止所做的:

使用 .jar 本身和 module.xml 为 .jar 创建一个文件夹:

<?xml version="1.0" encoding="UTF-8"?>
<!-- JDBC Drivers module.xml file to configure your JDBC drivers-->

<!-- SQL Server 2008 example -->
<module xmlns="urn:jboss:module:1.3" name="com.microsoft.sqlserver">
  <resources>
    <resource-root path="sqljdbc4.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

.. 在 C:\Program Files\Wildfly\wildfly-10.0.0.Final\modules\com\microsoft\sqlserver\main

在standalone.xml 中添加了数据源和驱动程序

<datasource jndi-name="java:jboss/datasources/DBName" pool-name="DBPoolName">
                    <connection-url>jdbc:microsoft:sqlserver://IP:Port;DatabaseName=DBName</connection-url>
                    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDataSource</driver-class>
                    <driver>sqlserver</driver>
                    <security>
                        <user-name>username</user-name>
                        <password>password</password>
                    </security>
                    <validation>
                        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
                    </validation>
                </datasource>

<driver name="sqlserver" module="com.microsoft.sqlserver">
                        <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDataSource</driver-class>
                    </driver>

我(可能??)用 MySQL 驱动程序做了同样的过程,没有任何问题。我也尝试通过Web界面wildfly管理添加数据源,但系统也找不到特定的驱动程序。

有没有人有任何想法?

谢谢你的时间!

4

1 回答 1

0

我有同样的问题,正确的配置是:standalone.xml

<driver name="sqlserver" module="com.microsoft.sqlserver">
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
    <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
</driver>

模块.xml

<module xmlns="urn:jboss:module:1.1" name="com.microsoft.sqlserver">
  <resources>
     <resource-root path="mssql-jdbc-6.2.2.jre8.jar"/>
  </resources>
  <dependencies>
      <module name="javax.api"/>
      <module name="javax.transaction.api"/>
  </dependencies>
</module>

测试软件:JbossEAP 7.2 JDK版本:8 SQL Server JDBC驱动版本:mssql-jdbc-6.2.2.jre8.jar

部分日志:

14:02:49,587 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 41) WFLYJCA0004: Deploying JDBC-compliant driver class com.microsoft.sqlserver.jdbc.SQLServerDriver (version 6.2) 14:02:49,589 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0018: Started Driver service with driver-name = sqlserver

问候。

于 2019-06-21T18:12:04.543 回答