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: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to