Skip navigation

Configuring a SQL Server data source is a two step process if performed on a new installation.

  1. Configure the SQL Server module
  2. Configure the data source pool

 

To create the SQL Server module, create the following folder structure under the modules directory.

<JBOSS INSTALLATION>\modules\com\microsoft\sqlserver\main

Copy the Microsoft SQL Server JDBC jar into the main folder.

Create a module.xml file in the main folder and copy the following.

[code]
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.microsoft.sqlserver">
<resources>
  <resource-root path="sqljdbc4-3.0.jar"/>
</resources>
<dependencies>
  <module name="javax.api"/>
  <module name="javax.transaction.api"/>
</dependencies>
</module>
[/code]

Next step is to configure the data source within the JBoss configuration of the system. Locate the data source subsystem

[code]
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
  ...
[/code]

And copy the following

[code]
<datasource
        jndi-name="java:/yellowfire/ds"
        pool-name="yellowfire.pool"
        enabled="true"
        jta="true"
        use-ccm="false">
<connection-url>jdbc:sqlserver://localhost\SQLSERVER2008R2:0;DatabaseName=xxx</connection-url>
<driver>sqlserver</driver>
<security>
   <user-name>user</user-name>
   <password>pwd</password>
</security>
<validation>
   <validate-on-match>false</validate-on-match>
   <background-validation>false</background-validation>
   <background-validation-millis>0</background-validation-millis>
</validation>
<statement>
   <prepared-statement-cache-size>0</prepared-statement-cache-size>
   <share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
[/code]

Now the you'll notice that in the <driver> node the value sqlserver, this is because this is not the actual driver class name but rather a link to a driver definition. The driver definition will make use of the module that was created earlier to actually load the database driver.  Copy the following driver definition to below or before the definition of the h2database database driver definition.

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

The zip containing the SQL Server module can be downloaded here.

Filter Blog