• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Getting error Reusltset is closed in was7

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bipra De wrote:Please let me know if i am wrong at any place.




read this : https://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: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was the easiest way to go. However, since Java 7, that can be improved using try-with-resources:
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic