Subject RE: [Firebird-Java] ResultSet closing
Author Robert DiFalco
Well, it's fairly straight-forward, you tried to close the result set
when it was already closed. Why not try this?

void doStuff( Connection con ) throws SQLException
{
PreparedStatement statement = con.prepareStatement( ... );

try
{
...

ResultSet rset = statement.executeQuery();

try
{
...
}
finally
{
rset.close();
}
}
finally
{
statement.close();
}
}

try
{
doStuff( con );
con.commit();
}
catch ( SQLException e )
{
try { con.rollback(); } catch ( Exception e } {}
}

You can use this basic pattern for updates or queries.



-----Original Message-----
From: nrajagopal35 [mailto:nrajagopal35@...]
Sent: Thursday, December 04, 2003 8:55 PM
To: Firebird-Java@yahoogroups.com
Subject: [Firebird-Java] ResultSet closing


Dear Team,

Does any one knows why JayBird throws "java.sql.SQLException: The
resultSet is closed", when the ResultSet is already closed.

According to specifications, if you close the statement then the
ResultSet also is closed.

In our code to make sure the closing of ResultSet and Statement, we
will close the ResultSet after closing Statement. In some cases to
ensure the closing, the same were closed in finally block for the
second time.

In these situations, SQLException is thrown with resultSet is closed.

Say in a block of code we are closing statement and again closing the
ResultSet in the try block. We catch SQLException and assume that
there is some problem in executing the query and do rollback. In these
cases SQLException thrown for ResultSet closed will be a problem.

So instead of throwing an SQLException just we will simply return
without throwing any Exception or at the
most we can log the message. Because SQLException can be thrown only
when some real problem occurs.

Kindly update me if anyone knows the reason behind this.

Thanks & Regards,
Rajagopal N


Yahoo! Groups Sponsor
ADVERTISEMENT




To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.