maxieduncan

Sunday, 25 October 2009

Setting up an XA datasource for SQL Server Express on JBoss

JBoss Configuration

Download the sql server jdbc driver from microsoft.  You will need to put this into the appropriate lib directory in jboss.  The driver also contains documentation on how to configure sql server for xa connections and it can also be on microsoft.com

Copy the default example config:

cp <JBOSS_HOME>/docs/examples/jca/mssql-xa-ds.xml <JBOSS_HOME>/server/default/deploy

Next update the config with your settings: 

<datasources>
  <xa-datasource>
    <jndi-name>JNDINAME</jndi-name>
    <track-connection-by-tx   />
    <isSameRM-override-value>false</isSameRM-override-value>
    <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
    <xa-datasource-property name="ServerName">HOSTNAME</xa-datasource-property>
    <xa-datasource-property name="DatabaseName">DBNAME</xa-datasource-property>
    <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
     <xa-datasource-property name="User">USERNAME</xa-datasource-property>
    <xa-datasource-property name="Password">PASSWORD</xa-datasource-property>
    <xa-datasource-property name="URL">jdbc:sqlserver://HOSTNAME:1433</xa-datasource-property>
      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
      <metadata>
         <type-mapping>MS SQLSERVER2000</type-mapping>
      </metadata>
  </xa-datasource>
</datasources>
Connecting via TCP
Configure SQL Server to enable TCP connections on a fixed port, instructions here.  When installing SQL Server make sure that select MIxed Mode for authentication.

You also need to make sure that your windows environment is setup to support transactions from a remote source, details for Vista are here.

Connecting via Parallels
If you are using a mac and running SQL Server via Parallels you need to use Bridged hosting for your VM

No comments:

Post a Comment