• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting error Reusltset is closed in was7  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using WAS7 server and getting the following error.
com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: ResultSet is closed.

here is my code.

private byte[] extractDocxDoc(String stdNumber) {
byte[] buf=null;
DatabaseAccessObject dao=null;
try {
dao = new DatabaseAccessObject(ApplicationManager.getConnectionConfig());
} catch (TCCException e1) {
// TODO Auto-generated catch block
LogManager.err("EXCEPTION--"+ e1.toString());
}
Blob blob =null;
InputStream iStream =null;
Statement stmnt=null;
ResultSet resultSet=null;
Connection con =null;
String query=AdressSQL.SQL_BLOB_ADRESS + stdNumber+ AdressSQL.WITH_UR;
try
{
con=dao.getConnection();
stmnt=con.createStatement();

resultSet = stmnt.executeQuery(query);
while(resultSet.next())
{
blob = resultSet.getBlob(AdressSQL.STD_BLOB_WPD);
iStream=blob.getBinaryStream();
String dataToIndex=extractText(iStream);
buf = dataToIndex.getBytes();
//buf= blob.getBytes(1,(int)blob.length());
}

}
catch(SQLException sql)
{
System.out.println("HERE IS THE PROBLEM--"+ sql.toString());
System.out.println("HERE IS THE PROBLEM123--"+ sql.getMessage());
LogManager.err("SQLException--"+ sql.toString());
}
catch(TCCException e)
{
LogManager.err("TCCException--"+ e.toString());
}
// amar change ends for SeRV00540613

finally
{
try {
resultSet.close();
stmnt.close();
con.close();
blob=null;
} catch (SQLException e) {
// TODO Auto-generated catch block
LogManager.err("EXCEPTION--"+ e.toString());
}
}
return buf;
}

Please let me know if i am wrong at any place. Any help will be appreciated.
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bipra De wrote:Please let me know if i am wrong at any place.



read this : http://www.coderanch.com/t/538094/java/java/close-sql-connection-finally-block

I like Campbell and Rob approach in the discussion.for instance,

neat?
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was the easiest way to go. However, since Java 7, that can be improved using try-with-resources:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!