|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.pow2.dao.AbstractDAO
Abstract Data access object.
Field Summary | |
protected static org.apache.log4j.Category |
cat
Log4J category. |
Constructor Summary | |
protected |
AbstractDAO()
Protected default constructor. |
Method Summary | |
boolean |
assertion(String tableName,
String condition)
Apply the input condition on the input table. |
protected void |
closeResources(Connection con,
boolean commit)
Commit or rollback any uncommitted transaction and close the input connection. |
protected void |
closeResources(ResultSet rs,
Statement st,
Connection con,
boolean commit)
Close the JDBC resultSet and statement objects, commit or rollback any uncommitted transaction and close the input connection. |
protected void |
closeResources(Statement st,
Connection con,
boolean commit)
Close the JDBC statement object, commit or rollback any uncommitted transaction and close the input connection. |
long |
count(String tableName)
Get the number of records from the input table. |
long |
count(String tableName,
String condition)
Get the number of records from the input table |
void |
delete(String tableName,
String condition)
Delete records from the input table, using the input condition. |
void |
delete(String tableName,
String condition,
Connection con)
Delete records from the input table, using the input condition. |
protected String |
encode(String statement)
Encode the input statement string, replacing all the "'" characters with "''" string. |
Connection |
getConnection()
Return a JDBC Connection. |
Connection |
getConnection(int isolationLevel)
Open a new transaction and return a JDBC Connection set with the input isolation level. |
long |
getNewKey()
Get a new unique key value. |
boolean |
isDebugEnabled()
Get the debug status. |
protected void |
populate(Object bean,
ResultSet resultSet)
Transfer a record data into the input value object bean. |
protected String |
setLike(String value)
set a SQL LIKE statement |
protected String |
setLike(String value,
boolean upperCase,
int likeMode)
set a SQL LIKE statement |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Category cat
Constructor Detail |
protected AbstractDAO()
Method Detail |
public boolean isDebugEnabled()
public boolean assertion(String tableName, String condition) throws Exception
tableName
- the name of the table where to apply the input conditioncondition
- the where condition string
Exception
- if any error occurspublic long count(String tableName) throws Exception
tableName
- the name of the table where to retrieve the records number
Exception
- if any error occurspublic long count(String tableName, String condition) throws Exception
tableName
- the name of the table where to retrieve the records numbercondition
- the where condition string, or null (stands for "no condition")
Exception
- if any error occurspublic long getNewKey() throws Exception
Exception
- Description of the Exceptionpublic void delete(String tableName, String condition) throws Exception
condition
- the query string.tableName
- Description of the Parameter
Exception
- Description of the Exceptionpublic void delete(String tableName, String condition, Connection con) throws Exception
tableName
- the name of the database tablecondition
- the query condition (a SQL 'where' clause
without the 'WHERE' word);con
- the JDBC Connection object.
Exception
- if any error occurspublic Connection getConnection() throws Exception
Exception
- Exception if any error occurspublic Connection getConnection(int isolationLevel) throws Exception
isolationLevel
- the isolation level to set the connection to
Exception
- if any error occursprotected String setLike(String value)
value
- the value to bound to the LIKE statement
protected String setLike(String value, boolean upperCase, int likeMode)
value
- the value to bound to the LIKE statementupperCase
- true to upper all the characters of the the input value stringlikeMode
- 0 stands for "contains": LIKE %${value}%
1 stands for "starts with": LIKE ${value}%
protected String encode(String statement)
statement
- the SQL statement string to encode
protected void populate(Object bean, ResultSet resultSet) throws SQLException
bean
- the value object to populate with the data retrieved
from the input resultSetresultSet
- the resultSet used to retrieve the record data from
SQLException
- if any error occursprotected void closeResources(Connection con, boolean commit) throws SQLException
finally()
clause.
con
- the Connection object to closecommit
- true to commit the transaction, false to rollback it
SQLException
- if any error occursprotected void closeResources(Statement st, Connection con, boolean commit) throws SQLException
finally()
clause.
st
- the Statement object to closecon
- the Connection object to closecommit
- true to commit the transaction, false to rollback it
SQLException
- if any error occursprotected void closeResources(ResultSet rs, Statement st, Connection con, boolean commit) throws SQLException
finally()
clause.
rs
- the recordSet object to closecon
- the Connection object to closest
- the statement object to closecommit
- true to commit the connection, false to rollback it
SQLException
- if any error occurs
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |