If you want to save lines, why not use a utility method in a class such as JDBCUtil? - like so:
public static void close ( ResultSet resultSet, Statement statement )
{
try
{
if( resultSet != null )
resultSet.close();
}
catch ( SQLException ignored ) {
// may be log the error here...
}
try
{
if( statement != null )
statement.close();
}
catch ( SQLException ignored ) {
// may be log the error here...
}
}
Then you can simply invoke this method. Anyways, from the
doc, as long as you generated the ResultSet from the statement that you want to close, you should be fine (assuming you are checking for nulls in the object.)
--
JDBC doc
getStatement
public Statement getStatement()
throws SQLException
Retrieves the Statement object that produced this ResultSet object. If the result set was generated some other way, such as by a DatabaseMetaData method, this method returns null.
Returns:
the Statment object that produced this ResultSet object or null if the result set was produced some other way
Throws:
SQLException - if a database access error occurs
Since:
1.2
--