Methods Summary |
---|
public void | doCatch(java.lang.Throwable t)Rollbacks the transaction and rethrows the Throwable.
if (conn != null) {
try {
conn.rollback();
} catch (SQLException e) {
// Ignore to not hide orignal exception
}
}
throw t;
|
public int | doEndTag()Commits the transaction.
try {
conn.commit();
} catch (SQLException e) {
throw new JspTagException(
Resources.getMessage("TRANSACTION_COMMIT_ERROR",
e.toString()), e);
}
return EVAL_PAGE;
|
public void | doFinally()Restores the Connection to its initial state and
closes it.
if (conn != null) {
try {
if ((isolation != Connection.TRANSACTION_NONE)
&& (isolation != origIsolation)) {
conn.setTransactionIsolation(origIsolation);
}
conn.setAutoCommit(true);
conn.close();
} catch (SQLException e) {
// Not much we can do
}
}
conn = null;
|
public int | doStartTag()Prepares for execution by setting the initial state, such as
getting the Connection and preparing it for
the transaction.
if ((rawDataSource == null) && dataSourceSpecified) {
throw new JspException(
Resources.getMessage("SQL_DATASOURCE_NULL"));
}
DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource,
pageContext);
try {
conn = dataSource.getConnection();
origIsolation = conn.getTransactionIsolation();
if (origIsolation == Connection.TRANSACTION_NONE) {
throw new JspTagException(
Resources.getMessage("TRANSACTION_NO_SUPPORT"));
}
if ((isolation != Connection.TRANSACTION_NONE)
&& (isolation != origIsolation)) {
conn.setTransactionIsolation(isolation);
}
conn.setAutoCommit(false);
} catch (SQLException e) {
throw new JspTagException(
Resources.getMessage("ERROR_GET_CONNECTION",
e.toString()), e);
}
return EVAL_BODY_INCLUDE;
|
public java.sql.Connection | getSharedConnection()Called by nested parameter elements to get a reference to
the Connection.
return conn;
|
private void | init()
conn = null;
dataSourceSpecified = false;
rawDataSource = null;
isolation = Connection.TRANSACTION_NONE;
|
public void | release()
init();
|
public void | setIsolation(java.lang.String iso)Setter method for the transaction isolation level.
if (TRANSACTION_READ_COMMITTED.equals(iso)) {
isolation = Connection.TRANSACTION_READ_COMMITTED;
} else if (TRANSACTION_READ_UNCOMMITTED.equals(iso)) {
isolation = Connection.TRANSACTION_READ_UNCOMMITTED;
} else if (TRANSACTION_REPEATABLE_READ.equals(iso)) {
isolation = Connection.TRANSACTION_REPEATABLE_READ;
} else if (TRANSACTION_SERIALIZABLE.equals(iso)) {
isolation = Connection.TRANSACTION_SERIALIZABLE;
} else {
throw new JspTagException(
Resources.getMessage("TRANSACTION_INVALID_ISOLATION"));
}
|