org.apache.james.util
Class JDBCUtil

java.lang.Object
  extended by org.apache.james.util.JDBCUtil

public abstract class JDBCUtil
extends java.lang.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.

Version:
CVS $Revision: 494012 $ $Date: 2007-01-08 10:23:58 +0000 (lun, 08 gen 2007) $

Constructor Summary
JDBCUtil()
           
 
Method Summary
 void closeJDBCConnection(java.sql.Connection conn)
          Closes database connection and logs if an error is encountered
 void closeJDBCResultSet(java.sql.ResultSet aResultSet)
          Closes database result set and logs if an error is encountered
 void closeJDBCStatement(java.sql.Statement stmt)
          Closes database statement and logs if an error is encountered
 boolean columnExists(java.sql.DatabaseMetaData dbMetaData, java.lang.String tableName, java.lang.String columnName)
          Checks database metadata to see if a column exists in a table Try UPPER, lower, and MixedCase, both on the table name and the column name, to see if the column is there.
 boolean columnExistsCaseSensitive(java.sql.DatabaseMetaData dbMetaData, java.lang.String tableName, java.lang.String columnName)
          Checks database metadata to see if a column exists in a table.
protected abstract  void delegatedLog(java.lang.String errorString)
          An abstract method which child classes override to handle logging of errors in their particular environments.
 boolean tableExists(java.sql.DatabaseMetaData dbMetaData, java.lang.String tableName)
          Checks database metadata to see if a table exists.
 boolean tableExistsCaseSensitive(java.sql.DatabaseMetaData dbMetaData, java.lang.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(java.lang.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(java.sql.DatabaseMetaData dbMetaData,
                           java.lang.String tableName)
                    throws java.sql.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:
java.sql.SQLException - if an exception is encountered while accessing the database

tableExistsCaseSensitive

public boolean tableExistsCaseSensitive(java.sql.DatabaseMetaData dbMetaData,
                                        java.lang.String tableName)
                                 throws java.sql.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:
java.sql.SQLException - if an exception is encountered while accessing the database

columnExists

public boolean columnExists(java.sql.DatabaseMetaData dbMetaData,
                            java.lang.String tableName,
                            java.lang.String columnName)
                     throws java.sql.SQLException
Checks database metadata to see if a column exists in a table Try UPPER, lower, and MixedCase, both on the table name and the column name, to see if the column is there.

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

columnExistsCaseSensitive

public boolean columnExistsCaseSensitive(java.sql.DatabaseMetaData dbMetaData,
                                         java.lang.String tableName,
                                         java.lang.String columnName)
                                  throws java.sql.SQLException
Checks database metadata to see if a column exists in a table. This method is sensitive to the case of both the provided table name and column name.

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

closeJDBCConnection

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

Parameters:
conn - the connection to be closed

closeJDBCStatement

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

Parameters:
stmt - the statement to be closed

closeJDBCResultSet

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

Parameters:
aResultSet - the result set to be closed


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.