I am getting a ClassCastException : org.apache.commoms.dbcp.DelegationgCallableStatement
while using DBCP1.2.1. I am using commons-dbcp1.2.1 with TomCat 4.1.29. to get the DBCPConnectionPool Object.
I use the OracleCallableStatement Object to call the geCursor() to retrieve the Cursor
Please see the Code snippet which generates error
Connection conn=null;
CallableStatement stmt=null;
ResultSet rs=null;
try{
//datasource will contain the javax.sql.DataSource after lookup
//Here we get the org.apache.commons.dbcp.PoolableConnection Object
conn=dataSource.getConnection();
stmt=conn.prepareCall(sql);
stmt.registerOutParameter(1,OracleTypes.CURSOR);
....//set the statement object values here
stmt.execute();
//get the Cursor here, here we get the ClassCastException
rs=((OracleCallableStatement)stmt).getCursor(1);
As an alternative, I tried to use the DelegatingConnection.getInnremostDelegate() to get the underlying connection and create the statement object from that. Still I get the same exception.
As this is an existing code, i have to use the OracleCallableStatement to get the Cursor.
Can you please suggest a work around for this ASAP
Thanks
Eldo Itteera
-
Apache DBCP ClassCastException : DelegatingCallableStatement (5 messages)
- Posted by: Eldo Itteera
- Posted on: November 24 2004 02:51 EST
Threaded Messages (5)
- Apache DBCP ClassCastException : DelegatingCallableStatement by Stefan Zobel on November 25 2004 15:37 EST
- I have another issue-I need to use BLOB by Eldo Itteera on November 30 2004 00:35 EST
-
I have another issue-I need to use BLOB by Stefan Zobel on November 30 2004 03:32 EST
- I have another issue-I need to use BLOB by Eldo Itteera on December 01 2004 01:00 EST
- I have another issue-I need to use BLOB by Stefan Zobel on December 01 2004 05:20 EST
-
I have another issue-I need to use BLOB by Stefan Zobel on November 30 2004 03:32 EST
- I have another issue-I need to use BLOB by Eldo Itteera on November 30 2004 00:35 EST
-
Apache DBCP ClassCastException : DelegatingCallableStatement[ Go to top ]
- Posted by: Stefan Zobel
- Posted on: November 25 2004 15:37 EST
- in response to Eldo Itteera
rs=((OracleCallableStatement)stmt).getCursor(1);
Can you please suggest a work around for this ASAP
Try
rs = (ResultSet) stmt.getObject(1);
instead.
Good luck,
Stefan -
I have another issue-I need to use BLOB[ Go to top ]
- Posted by: Eldo Itteera
- Posted on: November 30 2004 00:35 EST
- in response to Stefan Zobel
Thanks for your suggestion.Thats worked out.
but I have another issue. In another part of the code, I need to use Oracle BLOB to update the Object output stream.
Previously I have written the code to get the BLOB as follows. The statement object i used is like this
Connection conn=ds.getConnection();
Statement stmt=conn.createStatement(sql);
ResultSet rs=stmt.executeQuery();
//Here it will give the Class Cast exception for the DelegatingResultSet
BLOB lob_data=((OracleResultSet)rs).getBLOB().
ObjectOutputStream oos=new ObjectOutputStream(lob_data.getBinaryOutputStream());
oos.writeObject(content);
If I use Blob instead of Oracle BLOB, we dont have a method geBinaryOutputStream() in Blob, which is mandatory for me to update BLOB
Since this is available only in OracleResultSet, it wont work even if I take the ordinary result set.
Can you please suggest a work around for this
Thanks in advance
Eldo -
I have another issue-I need to use BLOB[ Go to top ]
- Posted by: Stefan Zobel
- Posted on: November 30 2004 15:32 EST
- in response to Eldo Itteera
ObjectOutputStream oos=new ObjectOutputStream(lob_data.getBinaryOutputStream());
oos.writeObject(content);
If I use Blob instead of Oracle BLOB, we dont have a method getBinaryOutputStream() in Blob, which is mandatory for me to update BLOB.
Why not simply
oracle.sql.BLOB lob_data = (oracle.sql.BLOB) rs.getBlob(i); ?
Kind regards,
Stefan -
I have another issue-I need to use BLOB[ Go to top ]
- Posted by: Eldo Itteera
- Posted on: December 01 2004 01:00 EST
- in response to Stefan Zobel
Thanks for your suggestion
Eventhough syntactically its is correct and compile the source code successfully, At runtime thsi gives ClassCastException oracle.sql.BLOB
Is there any other workaround for this?
Regards
Eldo -
I have another issue-I need to use BLOB[ Go to top ]
- Posted by: Stefan Zobel
- Posted on: December 01 2004 05:20 EST
- in response to Eldo Itteera
If I use Blob instead of Oracle BLOB, we dont have a method getBinaryOutputStream() in Blob, which is mandatory for me to update BLOBS
Try java.sql.Blob#setBinaryStream(long pos) instead of oracle.sql.BLOB#getBinaryOutputStream(long pos). This is new in JDBC 3.0 (JDK 1.4) and should work with the Oracle 10g JDBC driver.
Kind regards,
Stefan