Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

datasource lookup with jndi

843854Jul 30 2002 — edited Aug 4 2002
Hello,
I want to declare my database as a datasource in Tomcat4's server.xml, to use Tomcat4's connection pooling service. I've made the necessary changes in server.xml and my app's web.xml, and I'm using this code to do the lookup:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/myDb");
return ds.getConnection();

I'm getting this exception at line 3:
java.lang.ClassCastException: tyrex.jdbc.xa.EnabledDataSource

Apparently EnabledDataSource cannot be cast to DataSource ??? I also tried this code:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
ConnectionPoolDataSource pds = (ConnectionPoolDataSource)envCtx.lookup("jdbc/myDb");
PooledConnection ds = pds.getPooledConnection();
return ds.getConnection();

I would REALLY appreciate any help or suggestions!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 1 2002
Added on Jul 30 2002
3 comments
374 views