net.darkmist.alib.db
Class DbCloser

java.lang.Object
  extended by net.darkmist.alib.db.DbCloser

public class DbCloser
extends Object

Static methods to convinently close JDBC objects.


Method Summary
static Connection close(Connection conn)
          Handle closing a connection.
static Connection close(Connection conn, org.slf4j.Logger logExceptionTo)
          Handle closing a connection.
static Connection close(Connection conn, org.slf4j.Logger logExceptionTo, Object name)
          Handle closing a connection.
static PreparedStatement close(PreparedStatement stmt)
          Handle closing a prepared statment.
static PreparedStatement close(PreparedStatement stmt, org.slf4j.Logger logExceptionTo)
          Handle closing a prepared statment.
static PreparedStatement close(PreparedStatement stmt, org.slf4j.Logger logExceptionTo, Object name)
          Handle closing a prepared statment.
static ResultSet close(ResultSet rs)
          Handle closing a result set.
static ResultSet close(ResultSet rs, org.slf4j.Logger logExceptionTo)
          Handle closing a result set.
static ResultSet close(ResultSet rs, org.slf4j.Logger logExceptionTo, Object name)
          Handle closing a result set.
static ResultSet close(ResultSet rs, PreparedStatement stmt)
          Handle closing a result set and a prepared statment.
static ResultSet close(ResultSet rs, PreparedStatement stmt, Connection conn)
          Handle closing a result set and a prepared statment.
static ResultSet close(ResultSet rs, PreparedStatement stmt, Connection conn, org.slf4j.Logger logExceptionTo)
          Handle closing a result set and a prepared statment.
static ResultSet close(ResultSet rs, PreparedStatement stmt, Connection conn, org.slf4j.Logger logExceptionTo, Object name)
          Handle closing a result set and a prepared statment.
static ResultSet close(ResultSet rs, PreparedStatement stmt, org.slf4j.Logger logExceptionTo)
          Handle closing a result set and a prepared statment.
static ResultSet close(ResultSet rs, PreparedStatement stmt, org.slf4j.Logger logExceptionTo, Object name)
          Handle closing a result set and a prepared statment.
static Statement close(Statement stmt)
          Handle closing a statment.
static Statement close(Statement stmt, org.slf4j.Logger logExceptionTo)
          Handle closing a statment.
static Statement close(Statement stmt, org.slf4j.Logger logExceptionTo, Object name)
          Handle closing a statment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public static Statement close(Statement stmt,
                              org.slf4j.Logger logExceptionTo,
                              Object name)
Handle closing a statment.

Parameters:
stmt - The statement to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
name - Object to call Object.toString() on to name the object closed for any logged exception. If this is null stmt.toString() will be used.
Returns:
null as a convinence to null out the closed object.

close

public static Statement close(Statement stmt,
                              org.slf4j.Logger logExceptionTo)
Handle closing a statment. Calls close(Statement,Logger,Object) with null for the name

Parameters:
stmt - The statement to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
Returns:
null as a convinence to null out the closed object.

close

public static Statement close(Statement stmt)
Handle closing a statment. Calls close(Statement,Logger,Object) with null for logExceptionTo and name

Parameters:
stmt - The statement to close.
Returns:
null as a convinence to null out the closed object.

close

public static PreparedStatement close(PreparedStatement stmt,
                                      org.slf4j.Logger logExceptionTo,
                                      Object name)
Handle closing a prepared statment.

Parameters:
stmt - The statement to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
name - Object to call Object.toString() on to name the object closed for any logged exception. If this is null stmt.toString() will be used.
Returns:
null as a convinence to null out the closed object.

close

public static PreparedStatement close(PreparedStatement stmt,
                                      org.slf4j.Logger logExceptionTo)
Handle closing a prepared statment. Calls close(PreparedStatement,Logger,Object) with null for the name.

Parameters:
stmt - The statement to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.

close

public static PreparedStatement close(PreparedStatement stmt)
Handle closing a prepared statment. Calls close(PreparedStatement,Logger,Object) with null for logExceptionTo and name.

Parameters:
stmt - The statement to close.

close

public static ResultSet close(ResultSet rs,
                              org.slf4j.Logger logExceptionTo,
                              Object name)
Handle closing a result set.

Parameters:
rs - The result set to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
name - Object to call Object.toString() on to name the object closed for any logged exception. If this is null rs.toString() will be used.
Returns:
null as a convinence to null out the closed object.

close

public static ResultSet close(ResultSet rs,
                              org.slf4j.Logger logExceptionTo)
Handle closing a result set. Calls close(ResultSet,Logger,Object) with null for name.

Parameters:
rs - The result set to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
Returns:
null as a convinence to null out the closed object.

close

public static ResultSet close(ResultSet rs)
Handle closing a result set. Calls close(ResultSet,Logger,Object) with null for logExceptionTo and name

Parameters:
rs - The result set to close.

close

public static ResultSet close(ResultSet rs,
                              PreparedStatement stmt,
                              org.slf4j.Logger logExceptionTo,
                              Object name)
Handle closing a result set and a prepared statment. This calls close(ResultSet,Logger,Object) followed by close(PreparedStatement,Logger,Object).

Parameters:
rs - The result set to close.
stmt - The statement to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
name - Object to call Object.toString() on to name the object closed for any logged exception. If this is null rs.toString() will be used.
Returns:
null as a convinence to null out the closed objects.

close

public static ResultSet close(ResultSet rs,
                              PreparedStatement stmt,
                              org.slf4j.Logger logExceptionTo)
Handle closing a result set and a prepared statment. This calls close(ResultSet,PreparedStatement,Logger,Object) with null for name.

Parameters:
rs - The result set to close.
stmt - The statement to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
Returns:
null as a convinence to null out the closed objects.

close

public static ResultSet close(ResultSet rs,
                              PreparedStatement stmt)
Handle closing a result set and a prepared statment. This calls close(ResultSet,PreparedStatement,Logger,Object) with null for logException to and name.

Parameters:
rs - The result set to close.
stmt - The statement to close.
Returns:
null as a convinence to null out the closed objects.

close

public static Connection close(Connection conn,
                               org.slf4j.Logger logExceptionTo,
                               Object name)
Handle closing a connection.

Parameters:
conn - The conneciton to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
name - Object to call Object.toString() on to name the object closed for any logged exception. If this is null conn.toString() will be used.
Returns:
null as a convinence to null out the closed object.

close

public static Connection close(Connection conn,
                               org.slf4j.Logger logExceptionTo)
Handle closing a connection. Calls close(Connection,Logger,Object) with null for name.

Parameters:
conn - The conneciton to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
Returns:
null as a convinence to null out the closed object.

close

public static Connection close(Connection conn)
Handle closing a connection. Calls close(Connection,Logger,Object) with null for logException to and name.

Parameters:
conn - The conneciton to close.
Returns:
null as a convinence to null out the closed object.

close

public static ResultSet close(ResultSet rs,
                              PreparedStatement stmt,
                              Connection conn,
                              org.slf4j.Logger logExceptionTo,
                              Object name)
Handle closing a result set and a prepared statment. This calls close(ResultSet,Logger,Object), close(PreparedStatement,Logger,Object) and finally close(Connection,Logger,Object).

Parameters:
rs - The result set to close.
stmt - The statement to close.
conn - The connection to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
name - Object to call Object.toString() on to name the object closed for any logged exception.
Returns:
null as a convinence to null out the closed objects.

close

public static ResultSet close(ResultSet rs,
                              PreparedStatement stmt,
                              Connection conn,
                              org.slf4j.Logger logExceptionTo)
Handle closing a result set and a prepared statment. This calls close(ResultSet,PreparedStatement,Connection,Logger,Object) with null for name.

Parameters:
rs - The result set to close.
stmt - The statement to close.
conn - The connection to close.
logExceptionTo - The log to log any SQLException to. If this is null, the logger for the DbCloser class will be used.
Returns:
null as a convinence to null out the closed objects.

close

public static ResultSet close(ResultSet rs,
                              PreparedStatement stmt,
                              Connection conn)
Handle closing a result set and a prepared statment. This calls close(ResultSet,PreparedStatement,Connection,Logger,Object) with null for logExceptionTo and name.

Parameters:
rs - The result set to close.
stmt - The statement to close.
conn - The connection to close.
Returns:
null as a convinence to null out the closed objects.


Copyright © 2012. All Rights Reserved.