Meaningless Drivel is fun!*
The moose likes Websphere and the fly likes How can I interact with OracleResultSet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "How can I interact with OracleResultSet?" Watch "How can I interact with OracleResultSet?" New topic
Author

How can I interact with OracleResultSet?

Chris Delano
Greenhorn

Joined: Jan 20, 2004
Posts: 6
My end goal is to call OracleResultSet specific methods in WebSphere 5.1.x

How can I do this in WebSphere? It appears that WebSphere wraps ResultSet objects with its own: WSJdbcResultSet

JBoss wraps ResultSet objects with "WrappedResultSet" and has a method called "getUnderlyingResultSet()" which I can call to obtain the OracleResultSet and thus call OracleResultSet specific methods.

But "WSJdbcResultSet" has no such method! That's nice!

I tried using WSCallHelper.jdbcCall() to call an OracleResultSet specific method and that didn't work either. I received an SQLException:
Invalid Caller Type: com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet

But WSJdbcResultSet is the object wrapping the OracleResultSet on which I would like to call a method, so why would that be the invalid caller? Couldn't find any help on Google for that one.

So does anyone know how to obtain, or call methods on, the OracleResultSet object wrapped by WebSphere's WSJdbcResultSet object?

I looked around in the "JDBC Providers" section in the WebSphere admin console and couldn't find anywhere to configure WebSphere to basically not wrap the Oracle JDBC Driver classes with its own. Did I miss something?

Thanks a lot for any advice!

Chris
Tony Smith
Ranch Hand

Joined: Mar 15, 2005
Posts: 77
Can you just cast the result set to an OracleResultSet?
Chris Delano
Greenhorn

Joined: Jan 20, 2004
Posts: 6
No, I wasn't able to cast the returned 'ResultSet' because the object implementing the ResultSet interface in this case is WebSphere's WSJdbcResultSet and this object wraps OracleResultSet so I received a ClassCastException in my first attempt to obtain OracleResultSet.

I finally found some help on 'da web' and ended up getting the connection from the connection pool and then called:

to obtain a reference to the OracleConnection and then I was able to get to the OracleResultSet and call its methods.

Here is the helpful link I found.

http://www.dbforums.com/printthread.php?t=816566&pp=15

Hopefully this will help someone else.

Otherwise if someone thinks this is a potentially bad idea, please speak up!

Thanks,
Chris
Ceausu Catalin
Greenhorn

Joined: Jun 04, 2008
Posts: 1
Hi,
I know it is a very late response but maybe someone will find this usefull:
(It sets a BLOB)
Note that Hibernate session must be flushed before calling this code.




stmt = HibernateUtil.getSession().connection().createStatement();

String sqlText =
"SELECT pic_data " +
"FROM picture " +
"WHERE id=" + picture.getId() + " FOR UPDATE";
rset = stmt.executeQuery(sqlText);
boolean retnext = rset.next();

if ( retnext == false ) throw new Exception("picture row not found: " + picture.getId());

Object oraBLOB = WSCallHelper.jdbcCall(null, rset, "getBlob", new Object[] {new Integer(1)}, new Class[] {int.class});
logger.debug("WSCallHelper.jdbcCall returned:" + oraBLOB);

byte[] buffer = new byte[4096];

// avoid including oracle classes
Method mthd = oraBLOB.getClass().getMethod("getBinaryOutputStream", new Class[]{});
OutputStream outputStream = (OutputStream)mthd.invoke(oraBLOB, new Object[]{});

int length = -1;
while ((length = is.read(buffer)) != -1) {
outputStream.write(buffer, 0, length);
outputStream.flush();
}

rset.close();
stmt.close();
 
 
subject: How can I interact with OracleResultSet?