[#2499] Add JDBCUtils.safeClose(Connection)

This commit is contained in:
Lukas Eder 2013-06-02 19:04:23 +02:00
parent ea9cead111
commit 6f6dad4bf3

View File

@ -158,6 +158,21 @@ public class JDBCUtils {
return SQLDialect.SQL99;
}
/**
* Safely close a connection.
* <p>
* This method will silently ignore if <code>connection</code> is
* <code>null</code>, or if {@link Connection#close()} throws an exception.
*/
public static final void safeClose(Connection connection) {
if (connection != null) {
try {
connection.close();
}
catch (Exception ignore) {}
}
}
/**
* Safely close a statement.
* <p>