by admin on June 14, 2006 05:46pm


HOW-TO: CONNECTING SQL SERVER 2005 JDBC to JBOSS
We have been working in the labs regarding testing and integration of jBoss talking to a SQL server 2005 backend.

We have seen some questions on how to connect a SQL Server in the Windows environment to  jBoss. So I wrote a little how-to that describes just that.

It turns out that it is actually very simple.

Essentially, all that’s involved with installing the driver is:

  1. Download the jdbc driver from here; http://www.microsoft.com/downloads/details.aspx?familyid=e22bc83b-32ff-4474-a44a-22b6ae2c4e17&displaylang=en#filelist  (Scroll to the bottom of the screen)
  2. You can either download the Windows or Unix version. It does not really matter which one you use. For this example I use the Windows version.
  3. Run the downloaded exe file; this will create a directory called Microsoft SQL Server 2005 JDBC Driver in the directory you downloaded the file to.
  4. Copy the file Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar to your $JBOSS_HOME/server/default/lib
  5. Set your data source of your application to use the driver;
    <datasources>

    <local-tx-datasource>

        <jndi-name>DATASOURCENAME</jndi-name>

        <connection-url>jdbc:sqlserver://DATABASE URL;databaseName=jboss;</connection-url>

        <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>

        <user-name>DATABASE USERNAME</user-name>

        <password>DATABASE PASSWORD</password>

   </local-tx-datasource>

NOTE: Substitute DATASOURCE NAME, DATABASE-URL, DATABASE USERNAME and DATABASE PASSWORD for your local values.

And that is all there is to it. jBoss now should be able to connect to the SQL Server.

Special thanks to Dan Simonton one of our penguins who did a bunch of the testing on this.