Rakesh API

org.rakeshv.dbutils
Class CloseResources

java.lang.Object
  extended by org.rakeshv.dbutils.CloseResources

public class CloseResources
extends java.lang.Object

A convenience class to close JDBC resources in an error free manner. Any errors encountered while closing the resources will be logged using the logger. You can configure the location and other properties for the logger through the logging.properties file.

Version:
$Id: CloseResources.java,v 1.3 2005/03/03 02:19:08 rakesh Exp $
Author:
Rakesh Vidyadharan 25th August 2003

Copyright 2003 Rakesh Vidyadharan


Field Summary
static boolean CLOSE_ASSOCIATED_RESOURCES
          A constant used to indicate that all the JDBC resources associated with the specified resource should be closed.
static boolean CLOSE_SPECIFIED_RESOURCE
          A constant used to indicate that only the specified JDBC resource should be closed.
private static java.util.logging.Logger logger
          The logger instance used to log errors or other messages.
 
Constructor Summary
private CloseResources()
          Default constructor.
 
Method Summary
static void close(java.sql.Connection connection)
          Utility method to close the specified Connection in a fail-safe manner.
static void close(java.sql.Connection connection, boolean autoCommit)
          Utility method to close the specified Connection in a fail-safe manner.
static void close(java.sql.ResultSet resultSet)
          Utility method to close the specified ResultSet in a fail-safe manner.
static void close(java.sql.ResultSet resultSet, boolean closeAssociatedResources)
          Utility method to close the specified ResultSet in a fail-safe manner.
static void close(java.sql.Statement statement)
          Utility method to close the specified Statement in a fail-safe manner.
static void close(java.sql.Statement statement, boolean closeAssociatedResources)
          Utility method to close the specified Statement in a fail-safe manner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger
The logger instance used to log errors or other messages.


CLOSE_SPECIFIED_RESOURCE

public static final boolean CLOSE_SPECIFIED_RESOURCE
A constant used to indicate that only the specified JDBC resource should be closed.

false

See Also:
Constant Field Values

CLOSE_ASSOCIATED_RESOURCES

public static final boolean CLOSE_ASSOCIATED_RESOURCES
A constant used to indicate that all the JDBC resources associated with the specified resource should be closed.

See Also:
Constant Field Values
Constructor Detail

CloseResources

private CloseResources()
Default constructor. Cannot be instantiated.

Method Detail

close

public static void close(java.sql.ResultSet resultSet)
Utility method to close the specified ResultSet in a fail-safe manner. Any errors encountered while closing the result set will be logged to logger as a warning.

Parameters:
resultSet - The result set that is to be closed.

close

public static void close(java.sql.ResultSet resultSet,
                         boolean closeAssociatedResources)
Utility method to close the specified ResultSet in a fail-safe manner. If the closeAssociatedResources parameter is set to CLOSE_ASSOCIATED_RESOURCES, then the Statement and Connection associated with the specified result set are closed, otherwise, only the specifed result set will be closed.

Parameters:
resultSet - The result set that is to be closed.
closeAssociatedResources - The flag indicating the resources that are to be closed.
See Also:
close( ResultSet ), close( Statement ), close( Connection )

close

public static void close(java.sql.Statement statement)
Utility method to close the specified Statement in a fail-safe manner. Any errors encountered while closing the statement will be logged to logger as a warning.

Parameters:
statement - The statement that is to be closed.

close

public static void close(java.sql.Statement statement,
                         boolean closeAssociatedResources)
Utility method to close the specified Statement in a fail-safe manner. If the closeAssociatedResources parameter is set to CLOSE_ASSOCIATED_RESOURCES, then the Connection associated with the specified statement is also closed, otherwise, only the specifed statement will be closed.

Parameters:
statement - The statement that is to be closed.
closeAssociatedResources - The flag indicating the resources that are to be closed.
See Also:
close( Statement ), close( Connection )

close

public static void close(java.sql.Connection connection)
Utility method to close the specified Connection in a fail-safe manner. Any errors encountered while closing the connection will be logged to logger as a warning.

Parameters:
connection - The connection that is to be closed.

close

public static void close(java.sql.Connection connection,
                         boolean autoCommit)
Utility method to close the specified Connection in a fail-safe manner. Set the autoCommit property of the connection to the specified value. Any errors encountered while closing the connection will be logged to logger as a warning.

Parameters:
connection - The connection that is to be closed.
autoCommit - The value to set for the autoCommit property.
See Also:
close( Connection )

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan