public abstract class JdbcUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
TYPE_UNKNOWN
Constant that indicates an unknown (or unspecified) SQL type.
|
| Constructor and Description |
|---|
JdbcUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeResultSet(java.sql.ResultSet rs)
Close the given JDBC ResultSet and ignore any thrown exception.
|
static void |
closeStatement(java.sql.Statement stmt)
Close the given JDBC Statement and ignore any thrown exception.
|
static java.lang.Object |
getResultSetValue(java.sql.ResultSet rs,
int index)
Retrieve a JDBC column value from a ResultSet, using the most appropriate
value type.
|
static java.lang.String |
getValueForColumn(java.sql.ResultSet rs,
java.lang.String columnNameToCheck,
Database database)
Checks whether a result set has a column matching the specified column name.
|
static boolean |
isNumeric(int sqlType)
Check whether the given SQL type is numeric.
|
static java.lang.Object |
requiredSingleResult(java.util.Collection results)
Return a single result object from the given Collection.
|
public static final int TYPE_UNKNOWN
Types,
Constant Field Valuespublic static void closeStatement(java.sql.Statement stmt)
stmt - the JDBC Statement to close (may be null)public static void closeResultSet(java.sql.ResultSet rs)
rs - the JDBC ResultSet to close (may be null)public static java.lang.Object getResultSetValue(java.sql.ResultSet rs,
int index)
throws java.sql.SQLException
Uses the getObject(index) method, but includes additional "hacks"
to get around Oracle 10g returning a non-standard object for its TIMESTAMP
datatype and a java.sql.Date for DATE columns leaving out the
time portion: These columns will explicitly be extracted as standard
java.sql.Timestamp object.
rs - is the ResultSet holding the dataindex - is the column indexjava.sql.SQLException - if thrown by the JDBC APIBlob,
Clob,
Timestamppublic static boolean isNumeric(int sqlType)
sqlType - the SQL type to be checkedpublic static java.lang.Object requiredSingleResult(java.util.Collection results)
throws DatabaseException
Throws an exception if 0 or more than 1 element found.
results - the result Collection (can be null)DatabaseExceptionpublic static java.lang.String getValueForColumn(java.sql.ResultSet rs,
java.lang.String columnNameToCheck,
Database database)
throws java.sql.SQLException
rs - result set to checkcolumnNameToCheck - column name to checkjava.sql.SQLException