org.pojava.persistence.sql
Class TransConnection

java.lang.Object
  extended by org.pojava.persistence.sql.TransConnection
All Implemented Interfaces:
Connection

public class TransConnection
extends Object
implements Connection

This connection object provides a layer allowing a Transaction visibility to intervene (or interfere :) when a user of the connection performs transaction actions outside of those managed by the Transaction object itself. It mostly exists to allow a client to "close" a managed connection, and still have the connection participate in a transaction rollback.

Author:
John Pile

Field Summary
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
TransConnection(Connection conn)
          Create a new TransConnection from this connection.
 
Method Summary
 void clearWarnings()
          Clear connection warnings.
 void close()
          Close connection (ignored if closeAllowed is false).
 void commit()
          Commit transaction.
 Array createArrayOf(String typeName, Object[] elements)
          Unsupported.
 Blob createBlob()
          Unsupported.
 Clob createClob()
          Unsupported.
 Statement createStatement()
          Create a statement
 Statement createStatement(int resultSetType, int resultSetConcurrency)
          Create a statement
 Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Create a statement
 Struct createStruct(String str, Object[] objArray)
          Unsupported.
 boolean equals(Object obj)
          Compare two connections for equality.
 boolean getAutoCommit()
          Return true if autocommit is enabled.
 String getCatalog()
          Retrieve the connection catalog.
 Properties getClientInfo()
          Unsupported.
 String getClientInfo(String name)
          Unsupported.
 int getHoldability()
          Get connection's holdability
 DatabaseMetaData getMetaData()
          Get useful connection metadata
 int getTransactionIsolation()
          Get transaction isolation of connection.
 Map<String,Class<?>> getTypeMap()
          Get typeMap for connection.
 SQLWarning getWarnings()
          Get warnings from connection driver, which might not throw as Exceptions.
 int hashCode()
          HashCode of the connection.
 boolean isCloseAllowed()
          True if close will actually close the connection.
 boolean isClosed()
          Return true if connection is closed.
 boolean isReadOnly()
          Return true if connection is read only.
 boolean isValid(int timeout)
          Unsupported.
 boolean isWrapperFor(Class<?> arg0)
          Unsupported.
 String nativeSQL(String sql)
          Return the native equivalent of the given SQL statement.
 CallableStatement prepareCall(String sql)
          Prepare a callable statement.
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
          Prepare a callable statement.
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Prepare a callable statement.
 PreparedStatement prepareStatement(String sql)
          Prepare a prepared statement.
 PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
          Prepare a prepared statement.
 PreparedStatement prepareStatement(String sql, int[] columnIndexes)
          Prepare a prepared statement.
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
          Prepare a prepared statement.
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Prepare a prepared statement.
 PreparedStatement prepareStatement(String sql, String[] columnNames)
          Prepare a prepared statement.
 void releaseSavepoint(Savepoint savepoint)
          Release savepoint
 void rollback()
          Perform rollback
 void rollback(Savepoint savepoint)
          Rollback to savepoint
 void setAutoCommit(boolean autoCommit)
          Set AutoCommit
 void setCatalog(String catalog)
          Set catalog
 void setClientInfo(Properties properties)
          Unsupported.
 void setCloseAllowed(boolean closeAllowed)
          Set whether the underlying Connection is immediately closed by its close method.
 void setHoldability(int holdability)
          Set the connection's holdability
 void setReadOnly(boolean readOnly)
          Set read only attribute for the connection.
 Savepoint setSavepoint()
          Set a transaction savepoint for this connection.
 Savepoint setSavepoint(String name)
          Set a transaction savepoint for this connection.
 void setTransactionIsolation(int level)
          Set transaction Isolation defined in Connection object.
 void setTypeMap(Map<String,Class<?>> arg0)
          Set typeMap to new Map.
 String toString()
          Worthless conn.toString() output.
<T> T
unwrap(Class<T> iface)
          Unsupported.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransConnection

public TransConnection(Connection conn)
Create a new TransConnection from this connection.

Parameters:
conn -
Method Detail

clearWarnings

public void clearWarnings()
                   throws SQLException
Clear connection warnings.

Specified by:
clearWarnings in interface Connection
Throws:
SQLException

close

public void close()
           throws SQLException
Close connection (ignored if closeAllowed is false).

Specified by:
close in interface Connection
Throws:
SQLException

commit

public void commit()
            throws SQLException
Commit transaction.

Specified by:
commit in interface Connection
Throws:
SQLException

createStatement

public Statement createStatement()
                          throws SQLException
Create a statement

Specified by:
createStatement in interface Connection
Throws:
SQLException

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency)
                          throws SQLException
Create a statement

Specified by:
createStatement in interface Connection
Throws:
SQLException

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency,
                                 int resultSetHoldability)
                          throws SQLException
Create a statement

Specified by:
createStatement in interface Connection
Throws:
SQLException

getAutoCommit

public boolean getAutoCommit()
                      throws SQLException
Return true if autocommit is enabled.

Specified by:
getAutoCommit in interface Connection
Throws:
SQLException

getCatalog

public String getCatalog()
                  throws SQLException
Retrieve the connection catalog.

Specified by:
getCatalog in interface Connection
Throws:
SQLException

getHoldability

public int getHoldability()
                   throws SQLException
Get connection's holdability

Specified by:
getHoldability in interface Connection
Throws:
SQLException

getMetaData

public DatabaseMetaData getMetaData()
                             throws SQLException
Get useful connection metadata

Specified by:
getMetaData in interface Connection
Throws:
SQLException

getTransactionIsolation

public int getTransactionIsolation()
                            throws SQLException
Get transaction isolation of connection.

Specified by:
getTransactionIsolation in interface Connection
Throws:
SQLException

getTypeMap

public Map<String,Class<?>> getTypeMap()
                                throws SQLException
Get typeMap for connection.

Specified by:
getTypeMap in interface Connection
Throws:
SQLException

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Get warnings from connection driver, which might not throw as Exceptions.

Specified by:
getWarnings in interface Connection
Throws:
SQLException

isClosed

public boolean isClosed()
                 throws SQLException
Return true if connection is closed.

Specified by:
isClosed in interface Connection
Throws:
SQLException

isReadOnly

public boolean isReadOnly()
                   throws SQLException
Return true if connection is read only.

Specified by:
isReadOnly in interface Connection
Throws:
SQLException

nativeSQL

public String nativeSQL(String sql)
                 throws SQLException
Return the native equivalent of the given SQL statement.

Specified by:
nativeSQL in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql)
                              throws SQLException
Prepare a callable statement.

Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency)
                              throws SQLException
Prepare a callable statement.

Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
                              throws SQLException
Prepare a callable statement.

Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql)
                                   throws SQLException
Prepare a prepared statement.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
                                   throws SQLException
Prepare a prepared statement.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
                                   throws SQLException
Prepare a prepared statement.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
                                   throws SQLException
Prepare a prepared statement.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency)
                                   throws SQLException
Prepare a prepared statement.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws SQLException
Prepare a prepared statement.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)
                      throws SQLException
Release savepoint

Specified by:
releaseSavepoint in interface Connection
Throws:
SQLException

rollback

public void rollback()
              throws SQLException
Perform rollback

Specified by:
rollback in interface Connection
Throws:
SQLException

rollback

public void rollback(Savepoint savepoint)
              throws SQLException
Rollback to savepoint

Specified by:
rollback in interface Connection
Throws:
SQLException

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws SQLException
Set AutoCommit

Specified by:
setAutoCommit in interface Connection
Throws:
SQLException

setCatalog

public void setCatalog(String catalog)
                throws SQLException
Set catalog

Specified by:
setCatalog in interface Connection
Throws:
SQLException

setHoldability

public void setHoldability(int holdability)
                    throws SQLException
Set the connection's holdability

Specified by:
setHoldability in interface Connection
Throws:
SQLException

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws SQLException
Set read only attribute for the connection.

Specified by:
setReadOnly in interface Connection
Throws:
SQLException

setSavepoint

public Savepoint setSavepoint()
                       throws SQLException
Set a transaction savepoint for this connection.

Specified by:
setSavepoint in interface Connection
Throws:
SQLException

setSavepoint

public Savepoint setSavepoint(String name)
                       throws SQLException
Set a transaction savepoint for this connection.

Specified by:
setSavepoint in interface Connection
Throws:
SQLException

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws SQLException
Set transaction Isolation defined in Connection object.

Specified by:
setTransactionIsolation in interface Connection
Throws:
SQLException

setTypeMap

public void setTypeMap(Map<String,Class<?>> arg0)
                throws SQLException
Set typeMap to new Map.

Specified by:
setTypeMap in interface Connection
Throws:
SQLException

equals

public boolean equals(Object obj)
Compare two connections for equality.

Overrides:
equals in class Object

hashCode

public int hashCode()
HashCode of the connection.

Overrides:
hashCode in class Object

toString

public String toString()
Worthless conn.toString() output.

Overrides:
toString in class Object

isCloseAllowed

public boolean isCloseAllowed()
True if close will actually close the connection.

Returns:
true if close will actually close the underlying Connection

setCloseAllowed

public void setCloseAllowed(boolean closeAllowed)
Set whether the underlying Connection is immediately closed by its close method.

Parameters:
closeAllowed -

setClientInfo

public void setClientInfo(Properties properties)
Unsupported. Included to compile under Java 1.6.


createClob

public Clob createClob()
                throws SQLException
Unsupported. Included to compile under Java 1.6.

Throws:
SQLException

getClientInfo

public Properties getClientInfo()
                         throws SQLException
Unsupported. Included to compile under Java 1.6.

Throws:
SQLException

getClientInfo

public String getClientInfo(String name)
                     throws SQLException
Unsupported. Included to compile under Java 1.6.

Throws:
SQLException

createArrayOf

public Array createArrayOf(String typeName,
                           Object[] elements)
Unsupported. Included to compile under Java 1.6.


createBlob

public Blob createBlob()
                throws SQLException
Unsupported. Included to compile under Java 1.6.

Throws:
SQLException

isValid

public boolean isValid(int timeout)
                throws SQLException
Unsupported. Included to compile under Java 1.6.

Throws:
SQLException

isWrapperFor

public boolean isWrapperFor(Class<?> arg0)
                     throws SQLException
Unsupported. Included to compile under Java 1.6.

Throws:
SQLException

createStruct

public Struct createStruct(String str,
                           Object[] objArray)
Unsupported. Included to compile under Java 1.6.


unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Unsupported. Included to compile under Java 1.6.

Throws:
SQLException


Copyright © 2011. All Rights Reserved.