velosurf.sql
Class PooledPreparedStatement

java.lang.Object
  extended by velosurf.sql.PooledStatement
      extended by velosurf.sql.PooledPreparedStatement
All Implemented Interfaces:
RowHandler

public class PooledPreparedStatement
extends PooledStatement
implements RowHandler

this class encapsulates a jdbc PreparedStatement.

Author:
Claude Brisson

Field Summary
private  java.util.List columnNames
           
private  Entity entity
          the resulting entity.
private  java.sql.PreparedStatement preparedStatement
          wrapped prepared statement.
private static java.lang.Class valueParserSubClass
          org.apache.velocity.tools.generic.ValueParser$ValueParserSub class, if found in the classpath.
 
Fields inherited from class velosurf.sql.PooledStatement
connection, resultSet
 
Constructor Summary
PooledPreparedStatement(ConnectionWrapper connection, java.sql.PreparedStatement preparedStatement)
          build a new PooledPreparedStatement.
 
Method Summary
 void close()
          close this statement.
 java.lang.Object evaluate(java.util.List params)
          get a scalar result from this statement.
 java.lang.Object fetch(java.util.List params)
          get a unique object by id.
 java.lang.Object fetch(java.util.List params, Entity resultEntity)
          get a unique object by id and specify the Entity this object is an Instance of.
 java.lang.Object fetch(java.util.Map<java.lang.String,java.lang.Object> params, Entity resultEntity)
          get a unique object by id and specify the Entity this object is an Instance of.
 java.lang.Object get(java.lang.Object key)
          get the object value of the specified resultset column.
 ConnectionWrapper getConnection()
          get statement Connection.
 long getLastInsertID()
          get the last insert id.
 java.util.Set<java.lang.String> keySet()
          Get keys set.
 RowIterator query(java.util.List params)
          get the rowset.
 RowIterator query(java.util.List params, Entity resultEntity)
          get the rowset.
private  void setParams(java.util.List params)
          set prepared parameter values.
 int update(java.util.List params)
          issue the modification query of this prepared statement.
 
Methods inherited from class velosurf.sql.PooledStatement
getTagTime, isInUse, isValid, notifyInUse, notifyOver, resetTagTime, setInvalid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

valueParserSubClass

private static java.lang.Class valueParserSubClass
org.apache.velocity.tools.generic.ValueParser$ValueParserSub class, if found in the classpath.


columnNames

private java.util.List columnNames

preparedStatement

private java.sql.PreparedStatement preparedStatement
wrapped prepared statement.


entity

private Entity entity
the resulting entity.

Constructor Detail

PooledPreparedStatement

public PooledPreparedStatement(ConnectionWrapper connection,
                               java.sql.PreparedStatement preparedStatement)
build a new PooledPreparedStatement.

Parameters:
connection - database connection
preparedStatement - wrapped prepared statement
Method Detail

fetch

public java.lang.Object fetch(java.util.List params)
                       throws java.sql.SQLException
get a unique object by id.

Parameters:
params - parameter values
Returns:
fetched Instance
Throws:
java.sql.SQLException - thrown bu the database engine

fetch

public java.lang.Object fetch(java.util.List params,
                              Entity resultEntity)
                       throws java.sql.SQLException
get a unique object by id and specify the Entity this object is an Instance of.

Parameters:
params - parameter values
resultEntity - resulting entity
Returns:
the fetched Instance
Throws:
java.sql.SQLException - thrown by the database engine

fetch

public java.lang.Object fetch(java.util.Map<java.lang.String,java.lang.Object> params,
                              Entity resultEntity)
                       throws java.sql.SQLException
get a unique object by id and specify the Entity this object is an Instance of.

Parameters:
params - parameter values
resultEntity - resulting entity
Returns:
the fetched Instance
Throws:
java.sql.SQLException - thrown by the database engine

query

public RowIterator query(java.util.List params)
                  throws java.sql.SQLException
get the rowset.

Parameters:
params - parameter values
Returns:
the resulting row iterator
Throws:
java.sql.SQLException - thrown by the database engine

query

public RowIterator query(java.util.List params,
                         Entity resultEntity)
                  throws java.sql.SQLException
get the rowset.

Parameters:
params - parameter values
resultEntity - resulting entity
Returns:
resulting RowIterator
Throws:
java.sql.SQLException - thrown by the database engine

evaluate

public java.lang.Object evaluate(java.util.List params)
                          throws java.sql.SQLException
get a scalar result from this statement.

Parameters:
params - parameter values
Returns:
scalar result
Throws:
java.sql.SQLException - thrown bu the database engine

update

public int update(java.util.List params)
           throws java.sql.SQLException
issue the modification query of this prepared statement.

Parameters:
params - parameter values
Returns:
the numer of affected rows
Throws:
java.sql.SQLException - thrown by the database engine

get

public java.lang.Object get(java.lang.Object key)
                     throws java.sql.SQLException
get the object value of the specified resultset column.

Specified by:
get in interface RowHandler
Parameters:
key - the name of the resultset column
Returns:
the object value returned by jdbc
Throws:
java.sql.SQLException - thrown by the database engine

keySet

public java.util.Set<java.lang.String> keySet()
                                       throws java.sql.SQLException
Description copied from interface: RowHandler
Get keys set.

Specified by:
keySet in interface RowHandler
Returns:
keys set
Throws:
java.sql.SQLException

getLastInsertID

public long getLastInsertID()
                     throws java.sql.SQLException
get the last insert id.

Returns:
the last insert id
Throws:
java.sql.SQLException - thrown by the database engine

close

public void close()
           throws java.sql.SQLException
close this statement.

Specified by:
close in class PooledStatement
Throws:
java.sql.SQLException - thrown by the database engine

getConnection

public ConnectionWrapper getConnection()
get statement Connection.

Specified by:
getConnection in class PooledStatement
Returns:
the Connection object (usually a ConnectionWrapper object)

setParams

private void setParams(java.util.List params)
                throws java.sql.SQLException
set prepared parameter values.

Parameters:
params - parameter values
Throws:
java.sql.SQLException - thrown by the database engine


~ooOoo~