I have successfully configured a JDBC datasource in my JBoss standalone.xml
but I am also trying to figure out if it's possible to define the datasource in the web.xml itself, in a standard, container-agnostic way as this answer suggests.
However I am having trouble translating the elements from the JBoss's standalone.xml
into what I would need to put in my application's web.xml
.
Here's the excerpt from my JBoss standalone.xml
:
<datasource jta="false" jndi-name="java:/comp/env/jdbc/sybase/axafusers" pool-name="axafusers" enabled="true" use-ccm="false">
<connection-url>jdbc:jtds:sybase://localhost:12501/axafusers</connection-url>
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
<driver>sybasejtds</driver>
<security>
<user-name>username</user-name>
<password>secret</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
Defining the data source in the server as above works. However, the approach to define the data source in the web.xml
fails as shown below.
Here's what I have placed in my web.xml:
<data-source>
<name>java:/comp/env/jdbc/sybase/axafusers</name>
<class-name>net.sourceforge.jtds.jdbcx.JtdsDataSource</class-name>
<server-name>localhost</server-name>
<port-number>12501</port-number>
<database-name>axafusers</database-name>
<user>username</user>
<password>secret</password>
<transactional>false</transactional>
</data-source>
Despite my attempt to accurately copy the various parameters in their corresponding elements (the most error-prone part seems to be translating the connection-url
) I am consistently getting Could not create connection
messages that are ultimately caused by the following:
Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) [rt.jar:1.8.0_111] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) [rt.jar:1.8.0_111] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) [rt.jar:1.8.0_111] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) [rt.jar:1.8.0_111] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) [rt.jar:1.8.0_111] at java.net.Socket.connect(Socket.java:589) [rt.jar:1.8.0_111] at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:288) [jtds-1.3.1.jar:1.3.1] at net.sourceforge.jtds.jdbc.SharedSocket.(SharedSocket.java:251) [jtds-1.3.1.jar:1.3.1] at net.sourceforge.jtds.jdbc.JtdsConnection.(JtdsConnection.java:331) [jtds-1.3.1.jar:1.3.1]