public abstract class JDBCUtil extends Object
Helper class for managing common JDBC tasks.
This class is abstract to allow implementations to take advantage of different logging capabilities/interfaces in different parts of the code.
Constructor and Description |
---|
JDBCUtil() |
Modifier and Type | Method and Description |
---|---|
void |
closeJDBCConnection(Connection conn)
Closes database connection and logs if an error is encountered
|
void |
closeJDBCResultSet(ResultSet aResultSet)
Closes database result set and logs if an error is encountered
|
void |
closeJDBCStatement(Statement stmt)
Closes database statement and logs if an error is encountered
|
boolean |
columnExists(DatabaseMetaData dbMetaData,
String tableName,
String columnName)
Checks database metadata to see if a column exists in a table.
|
boolean |
columnExistsCaseSensitive(DatabaseMetaData dbMetaData,
String tableName,
String columnName)
Checks database metadata to see if a column exists in a table.
|
protected abstract void |
delegatedLog(String errorString)
An abstract method which child classes override to handle logging of
errors in their particular environments.
|
boolean |
tableExists(DatabaseMetaData dbMetaData,
String tableName)
Checks database metadata to see if a table exists.
|
boolean |
tableExistsCaseSensitive(DatabaseMetaData dbMetaData,
String tableName)
Checks database metadata to see if a table exists.
|
protected abstract void delegatedLog(String errorString)
errorString
- the error message generatedpublic boolean tableExists(DatabaseMetaData dbMetaData, String tableName) throws SQLException
dbMetaData
- the database metadata to be used to look up this tabletableName
- the table nameSQLException
- if an exception is encountered while accessing the databasepublic boolean tableExistsCaseSensitive(DatabaseMetaData dbMetaData, String tableName) throws SQLException
dbMetaData
- the database metadata to be used to look up this tabletableName
- the case sensitive table nameSQLException
- if an exception is encountered while accessing the databasepublic boolean columnExists(DatabaseMetaData dbMetaData, String tableName, String columnName) throws SQLException
dbMetaData
- the database metadata to be used to look up this columntableName
- the table namecolumnName
- the column nameSQLException
- if an exception is encountered while accessing the databasepublic boolean columnExistsCaseSensitive(DatabaseMetaData dbMetaData, String tableName, String columnName) throws SQLException
dbMetaData
- the database metadata to be used to look up this columntableName
- the case sensitive table namecolumnName
- the case sensitive column nameSQLException
- if an exception is encountered while accessing the databasepublic void closeJDBCConnection(Connection conn)
conn
- the connection to be closedpublic void closeJDBCStatement(Statement stmt)
stmt
- the statement to be closedpublic void closeJDBCResultSet(ResultSet aResultSet)
aResultSet
- the result set to be closedCopyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.