public class JDBCUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
safeClose(ResultSet resultSet)
Safely close a result set
This method will silently ignore if
resultSet is
null, or if ResultSet.close() throws an exception. |
static void |
safeClose(ResultSet resultSet,
PreparedStatement statement)
Safely close a result set and / or a statement
This method will silently ignore if
resultSet or
statement is null, or if
ResultSet.close() or Statement.close() throws an
exception. |
static void |
safeClose(Statement statement)
Safely close a statement
This method will silently ignore if
statement is
null, or if Statement.close() throws an exception. |
static void |
safeFree(Blob blob)
Safely free a blob
This method will silently ignore if
blob is
null, or if Blob.free() throws an exception. |
static void |
safeFree(Clob clob)
Safely free a clob
This method will silently ignore if
clob is
null, or if Clob.free() throws an exception. |
static <T> T |
wasNull(CallableStatement statement,
T value)
Convenient way to check if a JDBC-originated record was null
This is useful to check if primitive types obtained from the JDBC API
were actually SQL NULL values.
|
static <T> T |
wasNull(ResultSet rs,
T value)
Convenient way to check if a JDBC-originated record was null
This is useful to check if primitive types obtained from the JDBC API
were actually SQL NULL values.
|
static <T> T |
wasNull(SQLInput stream,
T value)
Convenient way to check if a JDBC-originated record was null
This is useful to check if primitive types obtained from the JDBC API
were actually SQL NULL values.
|
public static final void safeClose(Statement statement)
This method will silently ignore if statement is
null, or if Statement.close() throws an exception.
public static final void safeClose(ResultSet resultSet)
This method will silently ignore if resultSet is
null, or if ResultSet.close() throws an exception.
public static final void safeClose(ResultSet resultSet, PreparedStatement statement)
This method will silently ignore if resultSet or
statement is null, or if
ResultSet.close() or Statement.close() throws an
exception.
public static final void safeFree(Blob blob)
This method will silently ignore if blob is
null, or if Blob.free() throws an exception.
public static final void safeFree(Clob clob)
This method will silently ignore if clob is
null, or if Clob.free() throws an exception.
public static final <T> T wasNull(SQLInput stream, T value) throws SQLException
This is useful to check if primitive types obtained from the JDBC API were actually SQL NULL values.
stream - The data source from which a value was readvalue - The value that was readvalue or null if the
SQLInput.wasNull() is trueSQLExceptionpublic static final <T> T wasNull(ResultSet rs, T value) throws SQLException
This is useful to check if primitive types obtained from the JDBC API were actually SQL NULL values.
rs - The data source from which a value was readvalue - The value that was readvalue or null if the
ResultSet.wasNull() is trueSQLExceptionpublic static final <T> T wasNull(CallableStatement statement, T value) throws SQLException
This is useful to check if primitive types obtained from the JDBC API were actually SQL NULL values.
statement - The data source from which a value was readvalue - The value that was readvalue or null if the
CallableStatement.wasNull() is trueSQLExceptionCopyright © 2013. All Rights Reserved.