commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "chris markiewicz" <>
Subject want BasicDataSource from javax.sql.Datasource...
Date Mon, 28 Jun 2004 19:28:35 GMT
Hello.  I want a BasicDataSource object so that I can monitor some pool
statistics.  I grab a javax.sql.DataSource object (through jndi) but I
get a ClassCastException when I try to cast it to BasicDataSource.  So
the question is, how do I get a BasicDataSource when using DBCP/JNDI?

Snippet of code:
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/ci_common");
BasicDataSource bds = (BasicDataSource) ds;

The error occurs when I attempt the cast, obviously.  An odd aside, if I
send ds to the console, it says that it is of type BasicDataSource.

Excerpt of server.xml:
<Resource name="jdbc/globaldb" type="javax.sql.DataSource" />
  <ResourceParams name="jdbc/globaldb">
	pool params omitted..
<Context path="/xapp" docBase="xapp">
<ResourceLink name="jdbc/ci_common" global="jdbc/globaldb"
type="javax.sql.DataSource" />

Note that I did find a similar thread in the archives, but it didn't
help me.  It suggested removing the factory parameter and adding a
resource-ref entry to my web.xml.  Neither of those produced any

Thanks for your time.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message