Jboss MSSQL connection data source sample file
If you are trying to configure data source for JBoss application server for MSSQL database you could use below sample file:
- Make connection using net.sourceforge.jtds.jdbc.Driver (File name: mssql-ds.xml)
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>JNDINAME</jndi-name> <connection-url>jdbc:jtds:sqlserver://SERVERNAME:PORTNUMBER</connection-url> <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class> <user-name>USERNAME</user-name> <password>PASS</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>
- Make connection using com.microsoft.sqlserver.jdbc.SQLServerDriver
<datasources> <datasource jndi-name="java:/MSSQLDS" pool-name="MSSQLDS"> <connection-url>jdbc:sqlserver://SERVER_NAME:SERVER_PORT;databaseName=DB_NAME</connection-url> <driver>sqlserver2008</driver> <security> <user-name>USERNAME</user-name> <password>PASSWORD</password> </security> <pool> <min-pool-size>5</min-pool-size> <max-pool-size>50</max-pool-size> <prefill>false</prefill> <use-strict-min>false</use-strict-min> <flush-strategy>FailingConnectionOnly</flush-strategy> </pool> <validation> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"></valid-connection-checker> </validation> </datasource> <drivers> <driver name="sqlserver2008" module="com.microsoft"> <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class> </driver> </drivers> </datasources>
- If you are using JTDS driver to connect database please create above file and paste in ..server\default\deploy directory and also don’t forget to paste jtds-1.2.jar file ..server\default\lib folder
- If you are using SQLServer driver to connect database please create above file and paste in ..server\default\deploy directory and also don’t forget to paste sqljdbc4.jar file ..server\default\lib folder
- To test if configuration is working or not please follow this tutorial
- For more information please visit this JBoss tutorial