|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.data.util.sqlcontainer.query.AbstractTransactionalQuery
public abstract class AbstractTransactionalQuery
Common base class for database query classes that handle connections and transactions.
Method Summary | |
---|---|
void |
beginTransaction()
Reserves a connection with auto-commit off if no transaction is in progress. |
void |
commit()
Commits (if not in auto-commit mode) and releases the active connection. |
protected void |
ensureTransaction()
Check that a transaction is active. |
protected java.sql.Connection |
getConnection()
Returns the currently active connection, reserves and returns a new connection if no active connection. |
protected boolean |
isInTransaction()
|
protected void |
releaseConnection(java.sql.Connection conn,
java.sql.Statement statement,
java.sql.ResultSet rs)
Closes a statement and a resultset, then releases the connection if it is not part of an active transaction. |
void |
rollback()
Rolls back and releases the active connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void beginTransaction() throws java.lang.UnsupportedOperationException, java.sql.SQLException
java.lang.IllegalStateException
- if a transaction is already open
java.sql.SQLException
- if a connection could not be obtained or configured
java.lang.UnsupportedOperationException
public void commit() throws java.lang.UnsupportedOperationException, java.sql.SQLException
java.sql.SQLException
- if not in a transaction managed by this query
java.lang.UnsupportedOperationException
public void rollback() throws java.lang.UnsupportedOperationException, java.sql.SQLException
java.sql.SQLException
- if not in a transaction managed by this query
java.lang.UnsupportedOperationException
protected void ensureTransaction() throws java.sql.SQLException
java.sql.SQLException
- if no active transactionprotected void releaseConnection(java.sql.Connection conn, java.sql.Statement statement, java.sql.ResultSet rs) throws java.sql.SQLException
PreparedStatement
, its parameters are
cleared prior to closing the statement.
Although JDBC specification does state that closing a statement closes
its result set and closing a connection closes statements and result
sets, this method does try to close the result set and statement
explicitly whenever not null. This can guard against bugs in certain JDBC
drivers and reduce leaks in case e.g. closing the result set succeeds but
closing the statement or connection fails.
conn
- the connection to releasestatement
- the statement to close, may be null to skip closingrs
- the result set to close, may be null to skip closing
java.sql.SQLException
- if closing the result set or the statement failsprotected java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
protected boolean isInTransaction()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |