Methods Summary |
---|
public int | doEndTag()Commits the transaction, resets the auto commit flag and closes
the Connection (so it's returned to the pool).
try {
conn.commit();
conn.setAutoCommit(true);
conn.close();
}
catch (SQLException e) {
throw new JspException("SQL error: " + e.getMessage());
}
return EVAL_PAGE;
|
public int | doStartTag()Sets the Connection to be used by all nested DB actions.
conn = getTransactionConnection();
return EVAL_BODY_INCLUDE;
|
java.sql.Connection | getConnection()Returns the Connection used for the transaction. This
method is used by nested DB actions.
return conn;
|
private java.sql.Connection | getTransactionConnection()Gets a DataSource from the application scope, with the
name specified by the dataSource attribute, and prepares
it for transaction handling.
DataSource dataSource = (DataSource)
pageContext.getAttribute(dataSourceName, PageContext.APPLICATION_SCOPE);
if (dataSource == null) {
throw new JspException("dataSource " + dataSourceName + " not found");
}
try {
conn = dataSource.getConnection();
conn.setAutoCommit(false);
}
catch (SQLException e) {
throw new JspException("SQL error: " + e.getMessage());
}
return conn;
|
public void | release()Releases all instance variables.
dataSourceName = null;
conn = null;
super.release();
|
public void | setDataSource(java.lang.String dataSourceName)Sets the dataSource attribute.
this.dataSourceName = dataSourceName;
|