OOP SimpleDaoHelper Version 1.2

com.bentofw.dao
Class DaoHelperForPooledStatement

java.lang.Object
  extended by com.bentofw.dao.SimpleDaoHelperImpl
      extended by com.bentofw.dao.DaoHelperForPooledStatement
All Implemented Interfaces:
SimpleDaoHelper

public class DaoHelperForPooledStatement
extends SimpleDaoHelperImpl

Implementation of SimpleDaoHelper interface. This class creates PreparedStatement from PooledStatement.

OOP PooledStatement is the Java API for the pooling mechanism of JDBC PreparedStatement. Because the web applications in the real world execute the same set of PreparedStatement repeatedly, the pooling mechanism of PreparedStatement results in the significant performance improvement. In addition, its sophisticated Thread control makes your web applications rely Thread Safe.

To use this implementation, please download and install OOP PooledStatement. All the configuration information should be supplied in the property resource file. This property resource file is:

Based on the information in the above property file, this implementation picks up the appropriate PreparedStatement from the pool.

Author:
Jun Inamori
See Also:
SimpleDaoHelper

Constructor Summary
DaoHelperForPooledStatement()
          The constructor.
 
Method Summary
 void closeResource(java.sql.ResultSet res, java.sql.PreparedStatement ps, java.sql.Connection con, boolean isOK)
          This method closes only ResultSet.
 java.sql.Connection getConnection()
          Return the JDBC Connection.
 java.sql.PreparedStatement getPrepareStatement(java.sql.Connection con, java.lang.String sql)
          Return the JDBC PreparedStatement for the given SQL statement.
 
Methods inherited from class com.bentofw.dao.SimpleDaoHelperImpl
select, update
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DaoHelperForPooledStatement

public DaoHelperForPooledStatement()
                            throws NestedException,
                                   SimpleException
The constructor.

Throws:
NestedException
SimpleException
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Return the JDBC Connection.

This method returns null, because OOP PooledStatement keeps the Connection in its pool along with the PreparedStatement.

Specified by:
getConnection in interface SimpleDaoHelper
Specified by:
getConnection in class SimpleDaoHelperImpl
Returns:
Connection
Throws:
java.sql.SQLException

getPrepareStatement

public java.sql.PreparedStatement getPrepareStatement(java.sql.Connection con,
                                                      java.lang.String sql)
                                               throws java.sql.SQLException
Return the JDBC PreparedStatement for the given SQL statement.

This method picks the PreparedStatement from the pool of OOP PooledStatement. Because Connection is always null, please specify null as the first parameter.

Specified by:
getPrepareStatement in interface SimpleDaoHelper
Specified by:
getPrepareStatement in class SimpleDaoHelperImpl
Parameters:
con - JDBC Connection
sql - SQL statement
Returns:
PreparedStatement
Throws:
java.sql.SQLException

closeResource

public void closeResource(java.sql.ResultSet res,
                          java.sql.PreparedStatement ps,
                          java.sql.Connection con,
                          boolean isOK)
This method closes only ResultSet. And PreparedStatement will be pushed back to the pool.

This method closes only ResultSet. And PreparedStatement will be pushed back to the pool of OOP PooledStatement. As for Connection, this method does nothing, because it is always null.

Specified by:
closeResource in interface SimpleDaoHelper
Specified by:
closeResource in class SimpleDaoHelperImpl
Parameters:
res - ResultSet
ps - PreparedStatement
con - Connection
isOK - This parameter will be used only by DaoHelperForPooledStatement, because the PreparedStatement should not be pushed back to the pool if something is wrong. If SQLException is thrown while playing with PreparedStatement, please specify false. Otherwise, true.

OOP SimpleDaoHelper Version 1.2

ALL CONTENTS COPYRIGHT 2005, OOP-Research Corporation. All rights reserved.
Any questions and comments are welcome to OOP-Research Corporation.