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">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>url</name>
<value>omitted</value>
</parameter>
<parameter>
<name>driverClassName</name><value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter><name>username</name><value>omitted</value></parameter>
<parameter><name>password</name><value>omitted</value></parameter>
pool params omitted..
</ResourceParams>
...
<Context path="/xapp" docBase="xapp">
<ResourceLink name="jdbc/ci_common" global="jdbc/globaldb"
type="javax.sql.DataSource" />
</Context>
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
results.
Thanks for your time.
chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]