velosurf.sql
Class PooledPreparedStatement

java.lang.Object
  |
  +--velosurf.sql.Pooled
        |
        +--velosurf.sql.PooledPreparedStatement
All Implemented Interfaces:
DataAccessor

public class PooledPreparedStatement
extends Pooled
implements DataAccessor

this class encapsulates a jdbc PreparedStatement

Author:
Claude Brisson

Field Summary
protected  java.util.List mColumnNames
          column names
protected  DBConnection mDBConnection
          the database connection
protected  Entity mEntity
          the resulting entity
protected  boolean mMetaDone
          has meta information been fetched ?
protected  java.sql.PreparedStatement mPreparedStatement
          wrapped prepared statement
protected  java.sql.ResultSet mRS
          the result set
 
Fields inherited from class velosurf.sql.Pooled
mInUse, mTagTime, mUseOver
 
Constructor Summary
protected PooledPreparedStatement(DBConnection inDBConnection, java.sql.PreparedStatement inPreparedStatement)
          builds a new PooledPreparedStatement
 
Method Summary
 void close()
          close this statement
 java.lang.Object evaluate(java.util.List inParams)
          gets a scalar result from this statement
 java.lang.Object fetch(java.util.List inParams)
          get a unique object by id
 java.lang.Object fetch(java.util.List inParams, Entity inResultEntity)
          get a unique object by id and specify the Entity this object is an Instance of
 java.lang.Object fetch(java.util.Map inParams, Entity inResultEntity)
          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
 long getLastInsertID()
          get the last insert id - implemented only for mysql for now...
 RowIterator query(java.util.List inParams)
          gets the rowset
 RowIterator query(java.util.List inParams, Entity inResultEntity)
          gets the rowset
protected  void setParams(java.util.List inParams)
          set prepared parameter values
 int update(java.util.List inParams)
          issues the modification query of this prepared statement
 
Methods inherited from class velosurf.sql.Pooled
getTagTime, isInUse, notifyInUse, notifyOver, resetTagTime
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

mDBConnection

protected DBConnection mDBConnection
the database connection

mRS

protected java.sql.ResultSet mRS
the result set

mColumnNames

protected java.util.List mColumnNames
column names

mPreparedStatement

protected java.sql.PreparedStatement mPreparedStatement
wrapped prepared statement

mEntity

protected Entity mEntity
the resulting entity

mMetaDone

protected boolean mMetaDone
has meta information been fetched ?
Constructor Detail

PooledPreparedStatement

protected PooledPreparedStatement(DBConnection inDBConnection,
                                  java.sql.PreparedStatement inPreparedStatement)
builds a new PooledPreparedStatement
Parameters:
inDBConnection - database connection
inPreparedStatement - wrapped prepared statement
Method Detail

fetch

public java.lang.Object fetch(java.util.List inParams)
                       throws java.sql.SQLException
get a unique object by id
Parameters:
inParams - parameter values
Returns:
fetched Instance
Throws:
java.sql.SQLException - thrown bu the database engine

fetch

public java.lang.Object fetch(java.util.List inParams,
                              Entity inResultEntity)
                       throws java.sql.SQLException
get a unique object by id and specify the Entity this object is an Instance of
Parameters:
inParams - parameter values
inResultEntity - resulting entity
Returns:
the fetched Instance
Throws:
java.sql.SQLException - thrown by the database engine

fetch

public java.lang.Object fetch(java.util.Map inParams,
                              Entity inResultEntity)
                       throws java.sql.SQLException
get a unique object by id and specify the Entity this object is an Instance of
Parameters:
inParams - parameter values
inResultEntity - resulting entity
Returns:
the fetched Instance
Throws:
java.sql.SQLException - thrown by the database engine

query

public RowIterator query(java.util.List inParams)
                  throws java.sql.SQLException
gets the rowset
Parameters:
inParams - parameter values
Returns:
the resulting row iterator
Throws:
java.sql.SQLException - thrown by the database engine

query

public RowIterator query(java.util.List inParams,
                         Entity inResultEntity)
                  throws java.sql.SQLException
gets the rowset
Parameters:
inParams - parameter values
inResultEntity - resulting entity
Returns:
resulting RowIterator
Throws:
java.sql.SQLException - thrown by the database engine

evaluate

public java.lang.Object evaluate(java.util.List inParams)
                          throws java.sql.SQLException
gets a scalar result from this statement
Parameters:
inParams - parameter values
Returns:
scalar result
Throws:
java.sql.SQLException - thrown bu the database engine

update

public int update(java.util.List inParams)
           throws java.sql.SQLException
issues the modification query of this prepared statement
Parameters:
inParams - 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 DataAccessor
Parameters:
key - the name of the resultset column
Returns:
the object value returned by jdbc
Throws:
java.sql.SQLException - thrown by the database engine

getLastInsertID

public long getLastInsertID()
                     throws java.sql.SQLException
get the last insert id - implemented only for mysql for now...
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
Overrides:
close in class Pooled
Throws:
java.sql.SQLException - thrown by the database engine

setParams

protected void setParams(java.util.List inParams)
                  throws java.sql.SQLException
set prepared parameter values
Parameters:
inParams - parameter values
Throws:
java.sql.SQLException - thrown by the database engine


ooOoo