Groovy Documentation

griffon.plugins.hibernate3.internal
[Java] Class JdbcUtils

java.lang.Object
  griffon.plugins.hibernate3.internal.JdbcUtils

public abstract class JdbcUtils
extends Object

Generic utility methods for working with JDBC.

Contains code from Spring's org.springframework.jdbc.support.JdbcUtils.

Original author Thomas Risberg
Original author Juergen Hoeller

Authors:
Andres Almiray


Field Summary
private static org.slf4j.Logger LOG

 
Constructor Summary
JdbcUtils()

 
Method Summary
static void closeConnection(Connection con)

Close the given JDBC Connection and ignore any thrown exception.

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 extractDatabaseMetaData(DataSource dataSource, DatabaseMetaDataCallback action)

Extract database meta data via the given DatabaseMetaDataCallback.

static Object extractDatabaseMetaData(DataSource dataSource, String metaDataMethodName)

Call the specified method on DatabaseMetaData for the given DataSource, and extract the invocation result.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

LOG

private static final org.slf4j.Logger LOG


 
Constructor Detail

JdbcUtils

JdbcUtils()


 
Method Detail

closeConnection

public static void closeConnection(Connection con)
Close the given JDBC Connection and ignore any thrown exception. This is useful for typical finally blocks in manual JDBC code.
Parameters:
con - the JDBC Connection to close (may be null)


closeResultSet

public static void closeResultSet(ResultSet rs)
Close the given JDBC ResultSet and ignore any thrown exception. This is useful for typical finally blocks in manual JDBC code.
Parameters:
rs - the JDBC ResultSet to close (may be null)


closeStatement

public static void closeStatement(Statement stmt)
Close the given JDBC Statement and ignore any thrown exception. This is useful for typical finally blocks in manual JDBC code.
Parameters:
stmt - the JDBC Statement to close (may be null)


extractDatabaseMetaData

public static Object extractDatabaseMetaData(DataSource dataSource, DatabaseMetaDataCallback action)
Extract database meta data via the given DatabaseMetaDataCallback.

This method will open a connection to the database and retrieve the database metadata. Since this method is called before the exception translation feature is configured for a datasource, this method can not rely on the SQLException translation functionality.

Any exceptions will be wrapped in a MetaDataAccessException. This is a checked exception and any calling code should catch and handle this exception. You can just log the error and hope for the best, but there is probably a more serious error that will reappear when you try to access the database again.

throws:
MetaDataAccessException if meta data access failed
Parameters:
dataSource - the DataSource to extract metadata for
action - callback that will do the actual work
Returns:
object containing the extracted information, as returned by the DatabaseMetaDataCallback's processMetaData method


extractDatabaseMetaData

public static Object extractDatabaseMetaData(DataSource dataSource, String metaDataMethodName)
Call the specified method on DatabaseMetaData for the given DataSource, and extract the invocation result.
throws:
MetaDataAccessException if we couldn't access the DatabaseMetaData or failed to invoke the specified method
Parameters:
dataSource - the DataSource to extract meta data for
metaDataMethodName - the name of the DatabaseMetaData method to call
Returns:
the object returned by the specified DatabaseMetaData method
See Also:
DatabaseMetaData


 

Groovy Documentation