Configuring SQL Server JDBC Driver

431 views
Skip to first unread message

sconnall

unread,
Sep 13, 2018, 3:20:00 PM9/13/18
to Thorntail
I'm trying to configure a Thorntail 2.2.0.Final service to use the SQL Server JDBC driver for the following dependency. Any assistance or examples would be greatly appreciated. If this dependency is not supported I'm fine using an older one that is.

<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.0.0.jre8</version>
<scope>compile</scope>
</dependency>

My yaml file is setup exactly like my MySQL yaml setup used in another service, which works perfectly. Both services use JPA and reference the data source defined in the yaml files. No module.xml is used in that configuration.

swarm:
port:
offset: 7
datasources:
jdbc-drivers:
sqlserver:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
xa-datasource-class-name: com.microsoft.sqlserver.jdbc.SQLServerXADataSource
driver-module-name: com.microsoft
data-sources:
myDS:
driver-name: sqlserver
connection-url: jdbc:sqlserver://myserver:3306;database=mydatabase;
user-name: ********
password: ********
jta: true
use-java-context: true
min-pool-size: 5
max-pool-size: 10
idle-timeout-minutes: 1
blocking-timeout-millis: 5000
pool-prefill: true

The server log output is attached.  The data source referenced in the error in the log is defined as follows in my persistence.xml.

<persistence-unit name="MyPersistenceUnit" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/myDS</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2008Dialect" />
<property name="hibernate.id.new_generator_mappings" value="false" />
</properties>
</persistence-unit>
myserver.log

sconnall

unread,
Sep 13, 2018, 3:24:31 PM9/13/18
to Thorntail
I neglected to mention that I tried this with and without a modules resource with a module.xml and jdbc jar resource.  My modules directory looks like this:

modules/com/microsoft/sqlserver/main/module.xml

The jdbc jar is in the main directory.

The module.xml contains:

<module xmlns="urn:jboss:module:1.1" name="com.microsoft">
<resources>
<resource-root path="mssql-jdbc-7.0.0.jre8.jar"/>
</resources>

<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.xml.bind.api"/>
</dependencies>
</module>

sconnall

unread,
Sep 13, 2018, 4:21:48 PM9/13/18
to Thorntail
UPDATE:  

I changed the following and I'm now successfully loading the driver.  I had the module name set incorrectly in a few spots based off of some older non-Thorntail documentation.

I fixed this by changing driver-module-name to com.microsoft.sqlserver in my jdbc driver definition (in project-defaults.yml) and name to com.microsoft.sqlserver in my module.xml.

Finally, I removed the following from the build in my pom.xml.

<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

On Thursday, September 13, 2018 at 3:20:00 PM UTC-4, sconnall wrote:

Thomas Herzog

unread,
Sep 13, 2018, 5:25:58 PM9/13/18
to Thorntail
You shouldn't use resources-root tag, and shouldn't pollute your code base with the module jars.
Defines the jars like this examples show you.

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="biz.paluch.logging">
    <resources>
        <artifact name="biz.paluch.logging:logstash-gelf:1.11.2" />
        <artifact name="redis.clients:jedis:2.9.0" />
        <artifact name="org.apache.commons:commons-pool2:2.4.3" />
    </resources>

    <dependencies>
        <module name="org.apache.log4j" />
        <module name="org.slf4j" />
        <module name="javax.api" />
        <module name="org.jboss.logmanager" />
    </dependencies>
</module>


Thorntail will load the artifacts from maven, during the repackaging phase, when the standalone jar is created.
Reply all
Reply to author
Forward
0 new messages