org.apache.james.util
Class JDBCUtil

java.lang.Object
  |
  +--org.apache.james.util.JDBCUtil

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.

Author:
Noel Bergman , Peter M. Goldstein

Constructor Summary
JDBCUtil()
           
 
Method Summary
 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
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCUtil

public JDBCUtil()
Method Detail

delegatedLog

protected abstract void delegatedLog(String errorString)
An abstract method which child classes override to handle logging of errors in their particular environments.

Parameters:
errorString - the error message generated

tableExists

public boolean tableExists(DatabaseMetaData dbMetaData,
                           String tableName)
                    throws SQLException
Checks database metadata to see if a table exists. Try UPPER, lower, and MixedCase, to see if the table is there.

Parameters:
dbMetaData - the database metadata to be used to look up this table
tableName - the table name
Throws:
SQLException - if an exception is encountered while accessing the database

tableExistsCaseSensitive

public boolean tableExistsCaseSensitive(DatabaseMetaData dbMetaData,
                                        String tableName)
                                 throws SQLException
Checks database metadata to see if a table exists. This method is sensitive to the case of the provided table name.

Parameters:
dbMetaData - the database metadata to be used to look up this table
tableName - the case sensitive table name
Throws:
SQLException - if an exception is encountered while accessing the database

closeJDBCConnection

public void closeJDBCConnection(Connection conn)
Closes database connection and logs if an error is encountered

Parameters:
conn - the connection to be closed

closeJDBCStatement

public void closeJDBCStatement(Statement stmt)
Closes database statement and logs if an error is encountered

Parameters:
stmt - the statement to be closed

closeJDBCResultSet

public void closeJDBCResultSet(ResultSet aResultSet)
Closes database result set and logs if an error is encountered

Parameters:
aResultSet - the result set to be closed


"Copyright © 1999-2002 Apache Jakarta Project. All Rights Reserved."