6.4.1. Installing the JDBC Driver and Deploying the DataSource

6.4.1. Installing the JDBC Driver and Deploying the DataSource

To make the JDBC driver classes available to JBoss Application Server, copy the archive sqljdbc.jar from the sqljdbc_1.2 distribution to the lib directory in the default server configuration (assuming that is the server configuration you’re running).

Then create a text file in the deploy directory called mssql-ds.xml with the following datasource descriptor :

 
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
  <jndi-name>DefaultDS</jndi-name>
  <connection-url>jdbc:sqlserver://localhost:1433;DatabaseName=pubs</connection-url>
  <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
  <user-name>sa</user-name>
  <password>jboss</password>
  <check-valid-connection-sql>SELECT 1 FROM sysobjects</check-valid-connection-sql>
  <metadata>
	  <type-mapping>MS SQLSERVER2000</type-mapping>
  </metadata>
  </local-tx-datasource>
</datasources> 		

The datasource is pointing at a database “pubs” provided by default with MS SQL Server 2000.

Remember to update the connection url attributes as well as the username/password combination to match your environment setup.

Note

The class MSSQLValidConnectionChecker is provided with the AS distribution. Unfortunately it throws an exception when the latest 2005 version of the MS driver is installed http://jira.jboss.com/jira/browse/JBAS-4911.