tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "GB Developer" <gb107...@globallyboundless.com>
Subject RE: How do I acces the Underlying Connection of a Data Source?
Date Wed, 09 Nov 2005 19:31:56 GMT
if you're using the "PoolingDatasource", what is the result of calling: 

((org.apache.commons.dbcp.PoolingDataSource)ds).isAccessToUnderlyingConnecti
onAllowed()

Actually, I suppose it would be the wrapped tomcat version, so that cast
would be wrong. 

> -----Original Message-----
> From: Robert Upshall [mailto:rupshall@psasoft.com] 
> Sent: Wednesday, November 09, 2005 11:37 AM
> To: Tomcat Users List
> Subject: Re: How do I acces the Underlying Connection of a 
> Data Source?
> 
> 
> Its does, but it is returning null as well.  Only the 
> getConnection on 
> the data source returns a non-null value.
> 
> 
> GB Developer wrote:
> > does the org.apache.tomcat wrapped dbcp still expose 
> > getInnermostDelegate() ?
> > 
> > 
> >>Connection c = dc.getInnermostDelegate();
> >>log(c.getClass().getName() + ": " + c);
> > 
> > 
> > 
> > 
> >>-----Original Message-----
> >>From: Robert Upshall [mailto:rupshall@psasoft.com]
> >>Sent: Wednesday, November 09, 2005 10:34 AM
> >>To: Tomcat Users List
> >>Subject: How do I acces the Underlying Connection of a Data Source?
> >>
> >>
> >>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$PoolGuardConnect
> >>ionWrapper: 
> >>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
> >>
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


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


Mime
View raw message