|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jaeksoft.pojodbc.Transaction
public class Transaction
Represents a new database transaction. Currently, a transaction represents a database connection. Further implementation could share same connection.
Transaction automatically closed every Query used.
That source code is our recommended way to use it. You have close the transaction in a finally statement to be sure that the database connection will be released.
Transaction transaction = null; try { transaction = connectionManager.getNewTransaction(false, javax.sql.Connection.TRANSACTION_READ_COMMITTED); // ... do everything you need ... } finally { if (transaction != null) transaction.close(); }
Constructor Summary | |
---|---|
Transaction(java.sql.Connection cnx,
boolean autoCommit,
int transactionIsolation)
|
Method Summary | |
---|---|
void |
close()
Close all queries and the transaction. |
void |
commit()
Usual JDBC/SQL transaction commit |
Query |
prepare(java.lang.String sql)
Create a new Query |
Query |
prepare(java.lang.String sql,
int resultSetType,
int resultSetConcurency)
Create a new Query with standard JDBC properties. |
Query |
prepareWithKeys(java.lang.String sql)
Create a new Query with autogeneratedkey flag |
void |
rollback()
Usual JDBC/SQL transaction rollback |
int |
update(java.lang.String sql)
A convenient way to directly execute an INSERT/UPDATE/DELETE SQL statement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Transaction(java.sql.Connection cnx, boolean autoCommit, int transactionIsolation) throws java.sql.SQLException
java.sql.SQLException
Method Detail |
---|
public void close()
public void rollback() throws java.sql.SQLException
java.sql.SQLException
public void commit() throws java.sql.SQLException
java.sql.SQLException
public Query prepare(java.lang.String sql) throws java.sql.SQLException
sql
- The native SQL query
java.sql.SQLException
public Query prepareWithKeys(java.lang.String sql) throws java.sql.SQLException
sql
- The native SQL query
java.sql.SQLException
public Query prepare(java.lang.String sql, int resultSetType, int resultSetConcurency) throws java.sql.SQLException
ResultSetType and ResultSetConcureny are JDBC standard parameters like ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CONCUR_UPDATABLE, ...
sql
- The native SQL queryresultSetType
- A standard JDBC ResultSet typeresultSetConcurency
- A standard JDBC Result concurency property
java.sql.SQLException
public int update(java.lang.String sql) throws java.sql.SQLException
sql
- The native SQL query
java.sql.SQLException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |