tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Upshall <rupsh...@psasoft.com>
Subject How do I acces the Underlying Connection of a Data Source?
Date Wed, 09 Nov 2005 16:33:35 GMT
How do I access the underlying connection of a data source?  I am 
connecting to a DB2 database using the JTOpen drivers.  I define the 
context in the server.xml and the jndi lookup is successful, so is the 
getconnection on the datasource.  The problem is that I need access to 
the underlying connection (AS400JDBCConnection) but I cannot get past 
the Tomcat connection wrapper.  The getDelegate() method returns null 
instead of an underlying connection.  How can I force the wrapper to use 
  AS400JDBCConnection or how do I gain access to it?


server.xml:

<Context
  path="/myapp">
     <Resource
      name="jdbc/myDB"
      type="javax.sql.DataSource"
      password="something"
      driverClassName="com.ibm.as400.access.AS400JDBCDriver"
      maxIdle="3"
      maxWait="5000"
      username="someone"
      url="jdbc:as400://server;naming=system;libraries=lib1, 
lib2;errors=full"
      maxActive="10"/>
</Context>


code snipit:

. . .

InitialContext cxt = new InitialContext();

DataSource ds = (DataSource) cxt.lookup( "java:/comp/env/jdbc/myDB" );

DelegatingConnection dc = (DelegatingConnection) ds.getConnection();
log(dc.getClass().getName() + ": " + dc);

Connection c = dc.getDelegate();
log(c.getClass().getName() + ": " + c);

. . .

output:

INFO: Login: 
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper: 
org.apache.tomcat.dbcp.dbcp.PoolableConnection@682406



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message