Subject says it all... What am I doing wrong here? Apparently the WrappedCallableStatement implementation that JBoss uses is doing something to prevent the casting, but what do I do to get around that?
Code:
connection = getConnection("OracleDS");
logger.finer("Calling request_list.get_default_request_list");
cst = connection.prepareCall("{call request_list.get_default_request_list (?,?,?)}");
cst.setInt(1, 1);
cst.setInt(2, 1);
cst.registerOutParameter(3, OracleTypes.CURSOR);
cst.execute();
rs = ((OracleCallableStatement)cst).getCursor(3);
And getConnection is implemented as:
Code:
private java.sql.Connection getConnection (String resourceName)
throws NamingException, SQLException {
logger.finer("Obtaining JNDI context.");
//Obtain the JDNI context
Context context = new InitialContext();
logger.finer("JNDI Lookup to get the resource manager connection factory reference");
//JNDI Lookup to get the resource manager connection factory reference
javax.sql.DataSource ds = (javax.sql.DataSource) context.lookup("java:/jdbc/" + resourceName);
logger.finer("Invoke factory to obtain a connection and return connection to calling environment");
//Invoke factory to obtain a connection and return connection to calling
//environment
return ds.getConnection();
}
Discussions
EJB programming & troubleshooting: JBoss: ClassCastException during getCursor with Oracle...
-
JBoss: ClassCastException during getCursor with Oracle... (2 messages)
- Posted by: David O
- Posted on: June 21 2004 11:50 EDT
Threaded Messages (2)
- I figured it out... by David O on June 21 2004 17:05 EDT
- Re: JBoss: ClassCastException during getCursor with Oracle... by Ivan Lazarte on June 26 2009 11:32 EDT
-
I figured it out...[ Go to top ]
- Posted by: David O
- Posted on: June 21 2004 17:05 EDT
- in response to David O
I figured out how to do it.. For posterity I'll post it here...
cst = connection.prepareCall("{call
request_list.get_default_request_list (?,?,?)}");
cst.setInt(1, 1);
cst.setInt(2, 1);
cst.registerOutParameter(3, OracleTypes.CURSOR);
cst.execute();
rs = (ResultSet) cst.getObject(3);
Note that using getCursor doesn't work BUT getObject does provided I
tell the output parameter it's a oracle cursor.
Go figure - the one thing I didn't try was the way to fix it..
The reason for this is that JBoss called statements are implemented
via a WrappedCallableStatement (a JBoss object) and that can't be cast
to the OracleCallableStatement (which makes sense after I thought
about it a bit). However, you can register the output parameter as an
oracle type and then cast *that* to the result set.
Oh well.. learn something new every day I guess... :P -
Re: JBoss: ClassCastException during getCursor with Oracle...[ Go to top ]
- Posted by: Ivan Lazarte
- Posted on: June 26 2009 11:32 EDT
- in response to David O
Thanks a million! This is still valid as of JBOSS 4.2.2