org.j2ee.dao
Class AbstractJdbcDAOAction

java.lang.Object
  |
  +--org.j2ee.dao.AbstractJdbcDAOAction
All Implemented Interfaces:
DAOAction, JdbcDAOAction
Direct Known Subclasses:
JdbcOracleNTopQueryWrapperAction

public abstract class AbstractJdbcDAOAction
extends java.lang.Object
implements JdbcDAOAction


Based on an example of book Code Notes for J2EE, Edited by GREGORY BRILL, e-ISBN 0-679-64727-9
Last modified $Date: 2004/05/18 10:50:12 $

Version:
$Revision: 1.1.1.1 $
Author:
jvlio (jvlio@users.sourceforge.net)

Field Summary
 
Fields inherited from interface org.j2ee.dao.JdbcDAOAction
CALL_FUNCTION, CALL_PROCEDURE, DDL, NO_OUT_PARAM, QUERY, UPDATE
 
Constructor Summary
AbstractJdbcDAOAction()
           
AbstractJdbcDAOAction(int stmtType)
           
 
Method Summary
 void cachPreparedStatement(java.sql.PreparedStatement pstmt)
           
 void execute(org.j2ee.dao.DAOActionProcessor processor)
          This is the mainly method of an action.
 int[] getDataTypesForOutParams()
          This method is called when this action is of type CALL_PROCEDURE or CALL_FUNCTION.
 int[] getDataTypesForParams()
          This method retuns the SQL Type for parameters to be setted to sql statement.
 java.lang.Object[] getParameters()
          This method retuns the parameters to be setted to sql statement.
 java.sql.PreparedStatement getPreparedStatement()
           
abstract  java.lang.String getSQL()
          This method define the sql statement to be executed.
 int getStmtType()
          Return of statemnt's type.
 java.lang.Object getTO()
          REDEFINE THIS METHOD ON EVERY SUBCLASS The transfer object used or setted by the action.
 void handleResults(java.sql.CallableStatement cstmt)
          Handle the results of call statements.
If the statement is of type CALL_PROCEDURE or CALL_FUNCTION, then when the execution of the statement finalize and no exception occurs, this method is call for handle the results.
 void handleResults(int rowsAffected)
          Handle the results of update statements.
If the statement is of type UPDATE (insert, update or delete), then when the execution of the statement finalize and no exception occurs, this method is call for handle the results.
 void handleResults(java.sql.ResultSet rs)
          Handle the results of query statements.
If the statement is of type QUERY (select), then when the execution of the statement finalize and no exception occurs, this method is call for handle the results.
 boolean isCaching()
           
 boolean isCall()
          Returs true if this action is a CALL statement
 boolean isQuery()
          Returs true if this action is a QUERY statement
 boolean isUpdate()
          Returs true if this action is an UPDATE statement
 void setCaching(boolean caching)
           
 void setErrorHandler(org.j2ee.dao.DAOErrorHandler handler)
          This method allows to the action to set a class which manage application errors such as integrity constraint violated.
 void setStmtType(int stmtType)
          Set of statemnt's type.
 void setTO(java.lang.Object to)
          REDEFINE THIS METHOD ON EVERY SUBCLASS Set the private attribute, the transfer object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJdbcDAOAction

public AbstractJdbcDAOAction()

AbstractJdbcDAOAction

public AbstractJdbcDAOAction(int stmtType)
Method Detail

setTO

public void setTO(java.lang.Object to)
REDEFINE THIS METHOD ON EVERY SUBCLASS Set the private attribute, the transfer object. Concrete implementation of this interface must be properly implement this method to provide an uniform interface for all the actions.

Specified by:
setTO in interface DAOAction
Parameters:
to - (The Transfer Object used by the action)

getTO

public java.lang.Object getTO()
REDEFINE THIS METHOD ON EVERY SUBCLASS The transfer object used or setted by the action.

Specified by:
getTO in interface DAOAction
Returns:
the transfer object-

setErrorHandler

public void setErrorHandler(org.j2ee.dao.DAOErrorHandler handler)
This method allows to the action to set a class which manage application errors such as integrity constraint violated.

Specified by:
setErrorHandler in interface DAOAction
Parameters:
handler - a instance with the application code to manage the exception
See Also:
interface for a list of the code passed to method

getSQL

public abstract java.lang.String getSQL()
Description copied from interface: JdbcDAOAction
This method define the sql statement to be executed.

Specified by:
getSQL in interface JdbcDAOAction
Returns:
SQL Statement

getParameters

public java.lang.Object[] getParameters()
Description copied from interface: JdbcDAOAction
This method retuns the parameters to be setted to sql statement.

Specified by:
getParameters in interface JdbcDAOAction
Returns:
sql statement parameters values.

getDataTypesForParams

public int[] getDataTypesForParams()
Description copied from interface: JdbcDAOAction
This method retuns the SQL Type for parameters to be setted to sql statement. If this statement has not parameters, null can be returned.

Specified by:
getDataTypesForParams in interface JdbcDAOAction
Returns:
sql statement parameters types.
See Also:
Types

getDataTypesForOutParams

public int[] getDataTypesForOutParams()
Description copied from interface: JdbcDAOAction
This method is called when this action is of type CALL_PROCEDURE or CALL_FUNCTION. Retuns the SQL Type for out parameters.
The setings of out parametes begin with the first '?' mark and continue. If the only second '?' is an out parameter, then you can return an array like this:
return new int[] = {NO_OUT_PARAM, Types.VARCHAR};
If this statement has not out parameters, null can be returned.

Specified by:
getDataTypesForOutParams in interface JdbcDAOAction
Returns:
sql statement out parameters types.
See Also:
Types

cachPreparedStatement

public void cachPreparedStatement(java.sql.PreparedStatement pstmt)
Specified by:
cachPreparedStatement in interface JdbcDAOAction

getPreparedStatement

public java.sql.PreparedStatement getPreparedStatement()
Specified by:
getPreparedStatement in interface JdbcDAOAction

getStmtType

public int getStmtType()
Description copied from interface: JdbcDAOAction
Return of statemnt's type.

Specified by:
getStmtType in interface JdbcDAOAction
Returns:
one of this (QUERY,UPDATE,CALL_PROCEDURE,CALL_FUNCTION).

setStmtType

public void setStmtType(int stmtType)
Description copied from interface: JdbcDAOAction
Set of statemnt's type.

Specified by:
setStmtType in interface JdbcDAOAction
Parameters:
stmtType - one of this (QUERY,UPDATE,CALL_PROCEDURE,CALL_FUNCTION).

isQuery

public boolean isQuery()
Description copied from interface: JdbcDAOAction
Returs true if this action is a QUERY statement

Specified by:
isQuery in interface JdbcDAOAction

isUpdate

public boolean isUpdate()
Description copied from interface: JdbcDAOAction
Returs true if this action is an UPDATE statement

Specified by:
isUpdate in interface JdbcDAOAction

isCall

public boolean isCall()
Description copied from interface: JdbcDAOAction
Returs true if this action is a CALL statement

Specified by:
isCall in interface JdbcDAOAction

handleResults

public void handleResults(java.sql.ResultSet rs)
                   throws java.sql.SQLException
Description copied from interface: JdbcDAOAction
Handle the results of query statements.
If the statement is of type QUERY (select), then when the execution of the statement finalize and no exception occurs, this method is call for handle the results.

Specified by:
handleResults in interface JdbcDAOAction
Parameters:
rs - ResultSet returned by query.
java.sql.SQLException

handleResults

public void handleResults(int rowsAffected)
                   throws java.sql.SQLException
Description copied from interface: JdbcDAOAction
Handle the results of update statements.
If the statement is of type UPDATE (insert, update or delete), then when the execution of the statement finalize and no exception occurs, this method is call for handle the results.

Specified by:
handleResults in interface JdbcDAOAction
Parameters:
rowsAffected - Rows affecteds by execution of this action.
java.sql.SQLException

handleResults

public void handleResults(java.sql.CallableStatement cstmt)
                   throws java.sql.SQLException
Description copied from interface: JdbcDAOAction
Handle the results of call statements.
If the statement is of type CALL_PROCEDURE or CALL_FUNCTION, then when the execution of the statement finalize and no exception occurs, this method is call for handle the results.

Specified by:
handleResults in interface JdbcDAOAction
Parameters:
cstmt - CallableStatement used for execute this call.
java.sql.SQLException

execute

public void execute(org.j2ee.dao.DAOActionProcessor processor)
             throws DAOException
Description copied from interface: DAOAction
This is the mainly method of an action. Every action in this pattern must be executed with this method

Specified by:
execute in interface DAOAction
Parameters:
processor - (The procesor wich carry out with the action
Throws:
DAOException - If there where errors

isCaching

public boolean isCaching()
Specified by:
isCaching in interface JdbcDAOAction

setCaching

public void setCaching(boolean caching)
Specified by:
setCaching in interface JdbcDAOAction


Copyright © 2004 DAO Action Patterm. All Rights Reserved.