File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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
Bookmark "ConnectionPool DataSource error ClassCastException" Watch "ConnectionPool DataSource error ClassCastException" New topic
Author

ConnectionPool DataSource error ClassCastException

Rosalinde C
Greenhorn

Joined: Jul 02, 2002
Posts: 2
Hi,
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:
weblogic.jdbc.connectionPool.uidaePool=\
url=jdbc racle:thin:@serv1.line.net:1521:serv,\
driver=oracle.jdbc.driver.OracleDriver,\
initialCapacity=5,\
maxCapacity=20,\
capacityIncrement=1,\
props=user=user;password=pass
weblogic.jdbc.TXDataSource.myDataSource1=uidaePool
weblogic.allow.reserve.weblogic.jdbc.connectionPool.oraclePool=everyone
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,
Rosalinde
casalini@emedia.cv.net
Roger Graff
Ranch Hand

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

Joined: Jul 02, 2002
Posts: 2
Hi
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 =
(javax.sql.DataSource)PortableRemoteObject.narrow(ref,DataSource.class);
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: 566
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
Greenhorn

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.
Cheers,
Narendra.


Narendra Kamaraju
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ConnectionPool DataSource error ClassCastException