[#2499] Add JDBCUtils.safeClose(Connection)
This commit is contained in:
parent
ea9cead111
commit
6f6dad4bf3
@ -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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user