velosurf.sql
Class PooledPreparedStatement

java.lang.Object
  extended by velosurf.sql.Pooled
      extended by velosurf.sql.PooledPreparedStatement
All Implemented Interfaces:
ReadOnlyMap

public class PooledPreparedStatement
extends Pooled
implements ReadOnlyMap

this class encapsulates a jdbc PreparedStatement

Author:
Claude Brisson

Field Summary
protected  java.util.List columnNames
          column names
protected  ConnectionWrapper connection
          the connection
protected  Entity entity
          the resulting entity
protected  java.sql.PreparedStatement preparedStatement
          wrapped prepared statement
protected  java.sql.ResultSet resultSet
          the result set
private static java.lang.Class valueParserSubClass
           
 
Fields inherited from class velosurf.sql.Pooled
inUse, tagTime, useOver, valid
 
Constructor Summary
PooledPreparedStatement(ConnectionWrapper connection, java.sql.PreparedStatement preparedStatement)
          builds a new PooledPreparedStatement
 
Method Summary
 void close()
          close this statement
 java.lang.Object evaluate(java.util.List params)
          gets 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(ReadOnlyMap 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's Connection
 long getLastInsertID()
          get the last insert id - implemented only for mysql for now...
 java.util.Set keySet()
           
 RowIterator query(java.util.List params)
          gets the rowset
 RowIterator query(java.util.List params, Entity resultEntity)
          gets the rowset
protected  void setParams(java.util.List params)
          set prepared parameter values
 int update(java.util.List params)
          issues the modification query of this prepared statement
 
Methods inherited from class velosurf.sql.Pooled
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

connection

protected ConnectionWrapper connection
the connection


resultSet

protected java.sql.ResultSet resultSet
the result set


columnNames

protected java.util.List columnNames
column names


preparedStatement

protected java.sql.PreparedStatement preparedStatement
wrapped prepared statement


entity

protected Entity entity
the resulting entity

Constructor Detail

PooledPreparedStatement

public PooledPreparedStatement(ConnectionWrapper connection,
                               java.sql.PreparedStatement preparedStatement)
builds 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(ReadOnlyMap 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
gets 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
gets 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
gets 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
issues 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 ReadOnlyMap
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 keySet()
                     throws java.sql.SQLException
Specified by:
keySet in interface ReadOnlyMap
Throws:
java.sql.SQLException

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

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

getConnection

public ConnectionWrapper getConnection()
get statement's Connection

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

setParams

protected 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~