Modifier and Type | Field and Description |
---|---|
static int |
TYPE_UNKNOWN
Constant that indicates an unknown (or unspecified) SQL type.
|
Constructor and Description |
---|
JdbcUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
close(ResultSet rs,
Statement stmt) |
static void |
closeResultSet(ResultSet rs)
Close the given JDBC ResultSet and ignore any thrown exception.
|
static void |
closeStatement(Statement stmt)
Close the given JDBC Statement and ignore any thrown exception.
|
static Object |
getResultSetValue(ResultSet rs,
int index)
Retrieve a JDBC column value from a ResultSet, using the most appropriate
value type.
|
static String |
getValueForColumn(ResultSet rs,
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 Object |
requiredSingleResult(Collection results)
Return a single result object from the given Collection.
|
public static final int TYPE_UNKNOWN
Types
,
Constant Field Valuespublic static void closeStatement(Statement stmt)
stmt
- the JDBC Statement to close (may be null
)public static void closeResultSet(ResultSet rs)
rs
- the JDBC ResultSet to close (may be null
)public static Object getResultSetValue(ResultSet rs, int index) throws 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 indexSQLException
- if thrown by the JDBC APIBlob
,
Clob
,
Timestamp
public static boolean isNumeric(int sqlType)
sqlType
- the SQL type to be checkedpublic static Object requiredSingleResult(Collection results) throws DatabaseException
Throws an exception if 0 or more than 1 element found.
results
- the result Collection (can be null
)DatabaseException
public static String getValueForColumn(ResultSet rs, String columnNameToCheck, Database database) throws SQLException
rs
- result set to checkcolumnNameToCheck
- column name to checkSQLException
Copyright © 2023 Liquibase.org. All rights reserved.