OOP SimpleDaoHelper Version 1.2

com.bentofw.dao
Class DaoHelperForJdbc

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

public class DaoHelperForJdbc
extends SimpleDaoHelperImpl

Implementation of SimpleDaoHelper interface. This class creates PreparedStatement from JDBC Connection.

If the JNDI DataSource is available in your environment, please use DaoHelperForJndi instead of this implementation. Most J2EE application servers implement the sophisticated JNDI DataSource, and it will result in the better performance than the plain JDBC Connection.

To use this implementation, all the information required for establishing JDBC Connection should be supplied in the property resource file. This property resource file is:

The following properties must be specified:
Property nameValue
jdbc_drvThe fully qualified class name of your JDBC driver
jdbc_urlThe URL for the intended database
jdbc_usrThe user name for the specified database
jdbc_pssThe password for the specified database

Based on these information, this implementation establishes the JDBC Connection to your data base. And it creates PreparedStatement from this JDBC Connection.

Author:
Jun Inamori
See Also:
SimpleDaoHelper

Constructor Summary
DaoHelperForJdbc()
          The constructor.
 
Method Summary
 void closeResource(java.sql.ResultSet res, java.sql.PreparedStatement ps, java.sql.Connection con, boolean isOK)
          Close the specified ResultSet, PreparedStatment and Connection.
 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

DaoHelperForJdbc

public DaoHelperForJdbc()
                 throws NestedException,
                        SimpleException
The constructor.

Throws:
NestedException
SimpleException
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Return the JDBC Connection. Connection is created from DriverManager each time this method is called.

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 creates PreparedStatement from the specified Connection.

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)
Close the specified ResultSet, PreparedStatment and Connection.

Specified by:
closeResource in interface SimpleDaoHelper
Specified by:
closeResource in class SimpleDaoHelperImpl
Parameters:
res - ResultSet
ps - PreparedStatement
con - Connection
isOK - This parameter will be always ignored in this implementation. This parameter will be used only by DaoHelperForPooledStatement, because the PreparedStatement should not be pushed back to the pool if something is wrong. But, to make your code portable between the implementations, please specify the correct value. 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.