Package fr.paris.lutece.util.sql
Class Transaction
- java.lang.Object
-
- fr.paris.lutece.util.sql.Transaction
-
- Direct Known Subclasses:
MultiPluginTransaction
public class Transaction extends Object
Transaction
-
-
Field Summary
Fields Modifier and Type Field Description static intCOMMITTEDStatus for committed transactionsstatic intOPENEDStatus for opened transactionsstatic intROLLEDBACKStatus for roll backed transactions
-
Constructor Summary
Constructors Constructor Description Transaction()ConstructorTransaction(Plugin plugin)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit()Commit the transactionvoidexecuteStatement()Execute the current statementPreparedStatementgetStatement()The current prepared statementintgetStatus()Return the transaction statusPreparedStatementprepareStatement(String strSQL)Gets a prepared statementPreparedStatementprepareStatement(String strSQL, boolean bLogQueries)Gets a prepared statementPreparedStatementprepareStatement(String strSQL, Integer autoGeneratedKeys)Gets a prepared statementPreparedStatementprepareStatement(String strSQL, Integer autoGeneratedKeys, boolean bLogQueries)Gets a prepared statementvoidrollback()Rollback the transactionvoidrollback(Exception e)Rollback the transaction
-
-
-
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
-
prepareStatement
public PreparedStatement prepareStatement(String strSQL, Integer autoGeneratedKeys) throws SQLException
Gets a prepared statement- Parameters:
strSQL- The SQL statement- Returns:
- The prepared statement
- Throws:
SQLException- If an SQL error occurs
-
prepareStatement
public PreparedStatement prepareStatement(String strSQL, boolean bLogQueries) throws SQLException
Gets a prepared statement- Parameters:
strSQL- The SQL statement- Returns:
- The prepared statement
- Throws:
SQLException- If an SQL error occurs
-
prepareStatement
public PreparedStatement prepareStatement(String strSQL, Integer autoGeneratedKeys, boolean bLogQueries) throws SQLException
Gets a prepared statement- Parameters:
strSQL- The SQL statementautoGeneratedKeys- a flag indicating whether auto-generated keys should be returned; For example one ofStatement.RETURN_GENERATED_KEYSorStatement.NO_GENERATED_KEYS. SeePreparedStatement#prepareStatement(String, int)- Returns:
- The prepared statement
- Throws:
SQLException- If an SQL error occurs- Since:
- 6.0.0
-
getStatement
public PreparedStatement getStatement()
The current prepared statement- Returns:
- The current statement
-
executeStatement
public void executeStatement() throws SQLExceptionExecute 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
-
-