I added all the extra stuff because of the
jdbc wrapper I was trying to get the underlying resultset. Here is my original code that I have copied from my other application and the code works on jboss on the other application.
public void updateDrawing(BufferedInputStream bis) throws SQLException, EASException{
EASDBUtil easDBUtil = new EASDBUtil(logger);
Connection con = null;
int BUFFER_SIZE = 1024*2;
byte[] buffer = new byte[BUFFER_SIZE];//byte buffer 1024
byte[] tempBuffer = new byte[BUFFER_SIZE];//byte buffer 1024
int bytesRead = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
boolean badRecord = false;
int counter=0;
int totalBytesRead = 0;
OutputStream outbb = null;
GZIPOutputStream out = null;
// OracleResultSet rs = null;
ResultSet wrs = null;
int pkey = 0;
try {
//insert the empty blob so the record can be updated
con = easDBUtil.getConnection();
pstmt = con.prepareStatement(EASDBConstants.UPDATE_DRAWING);
pstmt.setInt(1,pkey);
rs = pstmt.executeQuery();
rs.next();
oracle.sql.BLOB blob=((oracle.jdbc.driver.OracleResultSet)rs).getBLOB(1);
outbb=blob.getBinaryOutputStream();
out = new GZIPOutputStream(outbb);
// Simple read/write loop.
while((bytesRead = bis.read(buffer)) != -1) {
counter=counter+1;
out.write(buffer, 0, bytesRead);
totalBytesRead = totalBytesRead + bytesRead;
out.flush();
}
}catch(EASException ce){
logger.error("Exception in updateDrawing", ce);
throw ce;
}catch(Exception e){
logger.error("Exception in updateDrawing", e);
throw new EASException("EAS_EXEC_001");
}finally{
easDBUtil.closeDBResources(con, pstmt, null, rs);
}
}
It fails on this line:
oracle.sql.BLOB blob=((oracle.jdbc.driver.OracleResultSet)rs).getBLOB(1);
With this error:
09:03:12,765 INFO [STDOUT] 09:03:12,359 ERROR [EASAttachDrawingDAO] Exception in updateDrawing
java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrappedResultSet
I have been stuck on this issue for a few days and I am very confused as to why it would be working differently from on app to another.
Thank you for your help.