It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes ConnectionPool DataSource error ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "ConnectionPool DataSource error ClassCastException" Watch "ConnectionPool DataSource error ClassCastException" New topic

ConnectionPool DataSource error ClassCastException

Rosalinde C

Joined: Jul 02, 2002
Posts: 2
I can not connect to a connection pool with a datasource. I can connect with the DriverManager.getConnection Method.
when I try to connect using the datasource I am getting this error:
java.lang.ClassCastException: weblogic.jdbc20.common.internal.RmiDataSource_ServiceStub
I am trying to connect from a jsp. This is the jsp code:
InitialContext initCtx = null;

Hashtable hashtable = new Hashtable();
hashtable.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
hashtable.put("java.naming.provider.url", _url1);
initCtx = new InitialContext(hashtable);
javax.sql.ConnectionPoolDataSource ds = (javax.sql.ConnectionPoolDataSource) initCtx.lookup ("myDataSource");
The entry I have in the weblogic properties is:
I am going crazy with this error. If anyone has any idea about why I am getting the error I would really appreciate your input.
Thank you,
Roger Graff
Ranch Hand

Joined: May 29, 2001
Posts: 112
Try using javax.sql.DataSource instead of javax.sql.ConnectionPoolDataSource.
Rosalinde C

Joined: Jul 02, 2002
Posts: 2
Thanks for getting back to me. Unfortunately I have tried using javax.sql.DataSource ds and
DataSource ds
neither one has made a difference. Ideally I would like to use javax.sql.DataSource not javax.sql.ConnectionPoolDataSource ds.
I have also tried using narrow operation:
Object ref = initCtx.lookup("myDataSource1");
javax.sql.DataSource ds =
and I still get the same error.
Please let me know if you have any other suggestions.
Thank you
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 567
Well what are you getting?

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Narendra Kamaraju

Joined: Jul 18, 2001
Posts: 16
Hi Rosalinde,
It looks like you are using the oracle drivers.
Try instantiating the oracle.jdbc.pool.OracleDataSource object rather than the javax.sql.DataSource.
I hope it should work.

Narendra Kamaraju
I agree. Here's the link:
subject: ConnectionPool DataSource error ClassCastException
It's not a secret anymore!