-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: c3p0 NewProxyCallableStatement exception
PostPosted: Tue Sep 02, 2008 12:10 pm 
Newbie

Joined: Tue Aug 05, 2008 1:18 am
Posts: 3
Hibernate version: 0.9.1.2

Name and version of the database you are using: Oracle 10 g

I have written one stored procedure taht returns cursor.
In java bussiness class this storedprocedure is called as follows.

////////////////////////////
Session session = Util_Hibernate.getSession();
Connection con = session.connection();
CallableStatement callStmt = con.prepareCall("{call SPTEEST_VIEW(?,?)}");
callStmt.setInt(1,iPointerKey);
callStmt.registerOutParameter(2,OracleTypes.CURSOR);
callStmt.execute();
cursor = ((OracleCallableStatement)callStmt).getCursor(2);



//////////////////

But last line throws following class cast exception when i use c3p0 connection pooling
com.mchange.v2.c3p0.impl.NewProxyCallableStatement.

But when I use hibernate default connection pooling, I am able to cast callStmt into OracleCallableStatement.

Plz tell me if anyone of you have come across this issue earlier. Is there any other workaround to return cursor from stored procedure using C3P0 connection.

Thanx in advance for suggestions.


Top
 Profile  
 
 Post subject: Re: c3p0 NewProxyCallableStatement exception
PostPosted: Wed Feb 02, 2011 4:41 pm 
Newbie

Joined: Wed Feb 02, 2011 4:29 pm
Posts: 1
I know it's been a while, but I have a solution to this problem.

As you said, when you use c3p0 connection pooling, the cursor should be a "NewProxyCallableStatement" and not an "OracleCallableStatement".
That is why you get this error.
I have had the same problem.

So to keep using c3p0, I have to use another way to get the cursor.
After calling:
Quote:
Session session = Util_Hibernate.getSession();
Connection con = session.connection();
CallableStatement callStmt = con.prepareCall("{call SPTEEST_VIEW(?,?)}");
callStmt.setInt(1,iPointerKey);
callStmt.registerOutParameter(2,OracleTypes.CURSOR);
callStmt.execute();


You should call:
Code:
ResultSet cursor = (ResultSet) callStmt.getObject(2);


If you are sure the output of your stored procedure is a "Ref Cursor", it should solve the problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.