This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I interact with OracleResultSet?

 
Chris Delano
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you just cast the result set to an OracleResultSet?
 
Chris Delano
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic