com.ora.jsp.tags.sql
Class TransactionTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--com.ora.jsp.tags.sql.TransactionTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.Tag

public class TransactionTag
extends javax.servlet.jsp.tagext.TagSupport

This class is a custom action for executing a SQL SELECT statement. The statement must be defined in the body of the action. It can contain ? place holders, replaced by the value of elements before execution. The number and order of place holders must match the number and order of elements in the body.

Version:
1.0
Author:
Hans Bergsten, Gefion software
See Also:
Serialized Form

Field Summary
private  java.sql.Connection conn
           
private  java.lang.String dataSourceName
           
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext, parent, values
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
TransactionTag()
           
 
Method Summary
 int doEndTag()
          Commits the transaction, resets the auto commit flag and closes the Connection (so it's returned to the pool).
 int doStartTag()
          Sets the Connection to be used by all nested DB actions.
(package private)  java.sql.Connection getConnection()
          Returns the Connection used for the transaction.
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.
 void release()
          Releases all instance variables.
 void setDataSource(java.lang.String dataSourceName)
          Sets the dataSource attribute.
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

dataSourceName

private java.lang.String dataSourceName

conn

private java.sql.Connection conn
Constructor Detail

TransactionTag

public TransactionTag()
Method Detail

setDataSource

public void setDataSource(java.lang.String dataSourceName)
Sets the dataSource attribute.
Parameters:
dataSource - the name of the DataSource object available in the application scope

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Sets the Connection to be used by all nested DB actions.
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Commits the transaction, resets the auto commit flag and closes the Connection (so it's returned to the pool).
Overrides:
doEndTag in class javax.servlet.jsp.tagext.TagSupport

release

public void release()
Releases all instance variables.
Overrides:
release in class javax.servlet.jsp.tagext.TagSupport

getConnection

java.sql.Connection getConnection()
Returns the Connection used for the transaction. This method is used by nested DB actions.

getTransactionConnection

private java.sql.Connection getTransactionConnection()
                                              throws javax.servlet.jsp.JspException
Gets a DataSource from the application scope, with the name specified by the dataSource attribute, and prepares it for transaction handling.