This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ConnectionPool DataSource error ClassCastException

 
Rosalinde C
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using javax.sql.DataSource instead of javax.sql.ConnectionPoolDataSource.
 
Rosalinde C
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well what are you getting?
 
Narendra Kamaraju
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic