Skip to content

Instantly share code, notes, and snippets.

@aziz781
Created October 28, 2011 09:38
Show Gist options
  • Save aziz781/1321971 to your computer and use it in GitHub Desktop.
Save aziz781/1321971 to your computer and use it in GitHub Desktop.
Data Source configuration for JBOSS
<!--(1) In web.xml (\WEB-INF\web.xml) add the following -->
<resource-ref>
<description>
Resource reference to a factory for java.sql.Connection
instances that may be used for talking to the database
that is configured in server.xml in TOMCAT.
For JBOSS- jboss-web.xml and *-ds.xml
</description>
<res-ref-name>jdbc/SampleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!--(2) In jboss-web.xml (\WEB-INF\ jboss-web.xml) add the following -->
<resource-ref>
<res-ref-name>jdbc/SampleDB</res-ref-name>
<jndi-name>java:/jdbc/SampleDS</jndi-name>
</resource-ref>
(res-ref-name in web.xml and jboss-web.xml should be the same)
(jdbc/SampleDS should match with jndi in *-ds.xml)
<!--(3) Add the following msssql-ds.xml (at server\default\deploy) -->
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/SampleDS</jndi-name>
<connection-url>jdbc:jtds:sqlserver://localhost:1433/sampleDB</connection-url>
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
<user-name>user</user-name>
<password>password</password>
<check-valid-connection-sql>SELECT 1 FROM sysobjects</check-valid-connection-sql>
<metadata>
<type-mapping>MS SQLSERVER2005</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
<!--(4) Add the required jar files in \server\default\lib FOLDER -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment