1 Reply Latest reply: May 3, 2012 12:01 PM by Mark Malakanov (user11181920) RSS

    Getting a javax.sql.DataSource connection from a connection URL

    srhcan

      How can I get a javax.sql.DataSource connection from a connection URL?

      I am using JBoss 4 Application Server. I have a DataSource with JNDI Name 'TestDS' setup:

      <datasources>
      <local-tx-datasource>
      <jndi-name>TestDS</jndi-name>
      <connection-url>jdbc:jtds:sqlserver://DBS2008R2/TestDB;tds=8.0;lastupdatecount=true</connection-url>
      <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
      <user-name>test_dbo</user-name>
      <password>test</password>
      <set-tx-query-timeout>true</set-tx-query-timeout>

      <!-- sql to call on an existing pooled connection when it is obtained from pool -->
      <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>

      <!-- Pooling Parameters -->
      <prepared-statement-cache-size>500</prepared-statement-cache-size>
      <min-pool-size>10</min-pool-size>
      <max-pool-size>40000</max-pool-size>
      </local-tx-datasource>
      </datasources>

      I want to perform these 3 steps:
      1) get the Connection URL from the DataSource with JNDI Name 'TestDS'
      2) modify that Connection URL
      3) get a javax.sql.DataSource connection using the modified Connection URL

      I have performed the first 2 steps but am not able to do the 3rd step. Is it possible to do it?