util
Class ManagedConnection

java.lang.Object
  |
  +--util.ManagedConnection

public class ManagedConnection
extends Object
implements Connection, Serializable

See Also:
Serialized Form

Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
ManagedConnection(String url)
           
ManagedConnection(String driver, String url)
           
 
Method Summary
 Connection baseConnection()
           
 void clearWarnings()
           
 void close()
           
 void commit()
           
 Statement createStatement()
          Create a managed statement, and return it.
 Statement createStatement(int t, int c)
           
 boolean getAutoCommit()
           
 String getCatalog()
           
 DatabaseMetaData getMetaData()
           
 int getTransactionIsolation()
           
 Map getTypeMap()
           
 SQLWarning getWarnings()
           
 boolean isClosed()
           
 boolean isReadOnly()
           
 String nativeSQL(String s)
           
 boolean needReconnect(SQLException e)
           
 CallableStatement prepareCall(String s)
           
 CallableStatement prepareCall(String s, int t, int c)
           
 PreparedStatement prepareStatement(String s)
           
 PreparedStatement prepareStatement(String s, int t, int c)
           
 ResultSet querySQL(String s)
          Helper function to execute queries with automatic reconnection.
 void reconnect()
          Establishes the given connection.
 boolean reconnectIfBad(SQLException e)
          Examines the given SQLException error, and tries to determine if the error is such that a reconnection is warranted.
 void rollback()
           
 void setAutoCommit(boolean a)
           
 void setCatalog(String c)
           
 void setReadOnly(boolean r)
           
 void setTransactionIsolation(int l)
           
 void setTypeMap(Map c)
           
 int updateSQL(String s)
          Helper function to execute statements with automatic reconnection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagedConnection

public ManagedConnection(String url)

ManagedConnection

public ManagedConnection(String driver,
                         String url)
Method Detail

reconnect

public void reconnect()
               throws SQLException
Establishes the given connection. If already connected, the old connection will be garbage collected.

updateSQL

public int updateSQL(String s)
              throws SQLException
Helper function to execute statements with automatic reconnection.

querySQL

public ResultSet querySQL(String s)
                   throws SQLException
Helper function to execute queries with automatic reconnection.

needReconnect

public boolean needReconnect(SQLException e)

reconnectIfBad

public boolean reconnectIfBad(SQLException e)
                       throws SQLException
Examines the given SQLException error, and tries to determine if the error is such that a reconnection is warranted. If so, it recreates the connection.

createStatement

public Statement createStatement()
                          throws SQLException
Create a managed statement, and return it. The ManagedStatement works with this class to keep connections alive.
Specified by:
createStatement in interface Connection

createStatement

public Statement createStatement(int t,
                                 int c)
                          throws SQLException
Specified by:
createStatement in interface Connection

prepareStatement

public PreparedStatement prepareStatement(String s)
                                   throws SQLException
Specified by:
prepareStatement in interface Connection

prepareStatement

public PreparedStatement prepareStatement(String s,
                                          int t,
                                          int c)
                                   throws SQLException
Specified by:
prepareStatement in interface Connection

prepareCall

public CallableStatement prepareCall(String s)
                              throws SQLException
Specified by:
prepareCall in interface Connection

prepareCall

public CallableStatement prepareCall(String s,
                                     int t,
                                     int c)
                              throws SQLException
Specified by:
prepareCall in interface Connection

nativeSQL

public String nativeSQL(String s)
                 throws SQLException
Specified by:
nativeSQL in interface Connection

setAutoCommit

public void setAutoCommit(boolean a)
                   throws SQLException
Specified by:
setAutoCommit in interface Connection

getAutoCommit

public boolean getAutoCommit()
                      throws SQLException
Specified by:
getAutoCommit in interface Connection

commit

public void commit()
            throws SQLException
Specified by:
commit in interface Connection

rollback

public void rollback()
              throws SQLException
Specified by:
rollback in interface Connection

close

public void close()
           throws SQLException
Specified by:
close in interface Connection

isClosed

public boolean isClosed()
                 throws SQLException
Specified by:
isClosed in interface Connection

getMetaData

public DatabaseMetaData getMetaData()
                             throws SQLException
Specified by:
getMetaData in interface Connection

setReadOnly

public void setReadOnly(boolean r)
                 throws SQLException
Specified by:
setReadOnly in interface Connection

isReadOnly

public boolean isReadOnly()
                   throws SQLException
Specified by:
isReadOnly in interface Connection

setCatalog

public void setCatalog(String c)
                throws SQLException
Specified by:
setCatalog in interface Connection

getCatalog

public String getCatalog()
                  throws SQLException
Specified by:
getCatalog in interface Connection

setTransactionIsolation

public void setTransactionIsolation(int l)
                             throws SQLException
Specified by:
setTransactionIsolation in interface Connection

getTransactionIsolation

public int getTransactionIsolation()
                            throws SQLException
Specified by:
getTransactionIsolation in interface Connection

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Specified by:
getWarnings in interface Connection

clearWarnings

public void clearWarnings()
                   throws SQLException
Specified by:
clearWarnings in interface Connection

setTypeMap

public void setTypeMap(Map c)
                throws SQLException
Specified by:
setTypeMap in interface Connection

getTypeMap

public Map getTypeMap()
               throws SQLException
Specified by:
getTypeMap in interface Connection

baseConnection

public Connection baseConnection()