fr.paris.lutece.util.sql
Class Transaction

java.lang.Object
  extended by fr.paris.lutece.util.sql.Transaction
Direct Known Subclasses:
MultiPluginTransaction

public class Transaction
extends Object

Transaction


Field Summary
static int COMMITTED
          Status for committed transactions
static int OPENED
          Status for opened transactions
static int ROLLEDBACK
          Status for roll backed transactions
 
Constructor Summary
Transaction()
          Constructor
Transaction(Plugin plugin)
          Constructor
 
Method Summary
protected  void beginTransaction(Plugin plugin)
          Begin a transaction
 void commit()
          Commit the transaction
 void executeStatement()
          Execute the current statement
protected  void finalize()
          Checks that the transaction has been committed (or rolled back) before being destroyed and release all transaction resources (statement, connection, ...) if not.
protected  Connection getConnection()
          Get the underlying connection.
 PreparedStatement getStatement()
          The current prepared statement
 int getStatus()
          Return the transaction status
 PreparedStatement prepareStatement(String strSQL)
          Gets a prepared statement
 void rollback()
          Rollback the transaction
 void rollback(Exception e)
          Rollback the transaction
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPENED

public static final int OPENED
Status for opened transactions

See Also:
Constant Field Values

COMMITTED

public static final int COMMITTED
Status for committed transactions

See Also:
Constant Field Values

ROLLEDBACK

public static final int ROLLEDBACK
Status for roll backed transactions

See Also:
Constant Field Values
Constructor Detail

Transaction

public Transaction()
Constructor


Transaction

public Transaction(Plugin plugin)
Constructor

Parameters:
plugin - The plugin owner of the transaction
Method Detail

prepareStatement

public PreparedStatement prepareStatement(String strSQL)
                                   throws SQLException
Gets a prepared statement

Parameters:
strSQL - The SQL statement
Returns:
The prepared statement
Throws:
SQLException - If an SQL error occurs

getStatement

public PreparedStatement getStatement()
The current prepared statement

Returns:
The current statement

executeStatement

public void executeStatement()
                      throws SQLException
Execute the current statement

Throws:
SQLException - If an SQL error occurs

commit

public void commit()
Commit the transaction


rollback

public void rollback()
Rollback the transaction


rollback

public void rollback(Exception e)
Rollback the transaction

Parameters:
e - The exception that cause the rollback

getStatus

public int getStatus()
Return the transaction status

Returns:
The transaction status

getConnection

protected Connection getConnection()
Get the underlying connection.

Returns:
The connection of this transaction. If the transaction has not begin, then return null.

beginTransaction

protected void beginTransaction(Plugin plugin)
Begin a transaction

Parameters:
plugin - The plugin owner of the transaction

finalize

protected void finalize()
                 throws Throwable
Checks that the transaction has been committed (or rolled back) before being destroyed and release all transaction resources (statement, connection, ...) if not.

Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 2014 Mairie de Paris. All rights reserved.