org.castor.cpa.persistence.sql.engine
Class CastorConnection

java.lang.Object
  extended by org.castor.cpa.persistence.sql.engine.CastorConnection

public final class CastorConnection
extends Object

CastorConnection class holding connection and factory parameters to encapsulate their usage in case of creation of CastorStatements.

Version:
$Revision: 8994 $ $Date: 2011-08-02 01:40:59 +0200 (Di, 02 Aug 2011) $
Author:
Dennis Butterstein, Ralf Joachim

Constructor Summary
CastorConnection(PersistenceFactory factory, Connection connection)
          Constructor.
 
Method Summary
 void close()
          Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.
 void commit()
          Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by this Connection object.
 CastorStatement createStatement()
          Method to create new CastorStatement using local instances of Connection & PersistenceFactory.
 Connection getConnection()
          Getter returning current _connection.
 void rollback()
          Undoes all changes made in the current transaction and releases any database locks currently held by this Connection object.
 void setAutoCommit(boolean autoCommit)
          Sets this connection's auto-commit mode to the given state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CastorConnection

public CastorConnection(PersistenceFactory factory,
                        Connection connection)
Constructor.

Parameters:
factory - Instance of PersistenceFactory to be used to create CastorStatements.
connection - Instance of the connection to be used to create CastorStatements.
Method Detail

createStatement

public CastorStatement createStatement()
Method to create new CastorStatement using local instances of Connection & PersistenceFactory.

Returns:
New instance of CastorStatement.

getConnection

public Connection getConnection()
Getter returning current _connection.

Returns:
Connection currently set.

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws SQLException
Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode.

Parameters:
autoCommit - true to enable auto-commit mode; false to disable it
Throws:
SQLException - if a database access error occurs

commit

public void commit()
            throws SQLException
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by this Connection object. This method should be used only when auto-commit mode has been disabled.

Throws:
SQLException - if a database access error occurs or this Connection object is in auto-commit mode.

rollback

public void rollback()
              throws SQLException
Undoes all changes made in the current transaction and releases any database locks currently held by this Connection object. This method should be used only when auto-commit mode has been disabled.

Throws:
SQLException - if a database access error occurs or this Connection object is in auto-commit mode.

close

public void close()
           throws SQLException
Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.

Calling the method close on a Connection object that is already closed is a no-op.

Note: A Connection object is automatically closed when it is garbage collected. Certain fatal errors also close a Connection object.

Throws:
SQLException - if a database access error occurs.


Copyright © 2012. All Rights Reserved.