velosurf.sql
Class PooledStatement

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

public class PooledStatement
extends Pooled
implements DataAccessor

this class encapsulates a jdbc Statement

Author:
Claude Brisson

Field Summary
protected  java.util.List mColumnNames
          column names in natural order
protected  DBConnection mDBConnection
          database connection
protected  java.lang.String mQuery
          SQL query
protected  java.sql.ResultSet mRS
          result set
protected  java.sql.Statement mStatement
          wrapped statement
 
Fields inherited from class velosurf.sql.Pooled
mInUse, mTagTime, mUseOver
 
Constructor Summary
protected PooledStatement(DBConnection inDBConnection, java.sql.Statement inStatement)
          builds a new PooledStatement
 
Method Summary
 void close()
          close thos statement
 java.lang.Object evaluate(java.lang.String inQuery)
          evaluates the SQL query as a scalar
 java.lang.Object fetch(java.lang.String inQuery)
          fetch a single row
 java.lang.Object fetch(java.lang.String inQuery, Entity inResultEntity)
          fetch a single row, specyfing the entity it belongs to
 java.lang.Object get(java.lang.Object key)
          get specified column as an object
 long getLastInsertID()
          gets the last insert id
 void notifyOver()
          notify this statement is no more used and can be recycled
 RowIterator query(java.lang.String inQuery)
          gets the resultset for this statement
 RowIterator query(java.lang.String inQuery, Entity inResultEntity)
          gets the resultset for this statement, specifying the entity the results belong to
 int update(java.lang.String inQuery)
          issues the update contained in the query
 
Methods inherited from class velosurf.sql.Pooled
getTagTime, isInUse, notifyInUse, resetTagTime
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

mQuery

protected java.lang.String mQuery
SQL query

mDBConnection

protected DBConnection mDBConnection
database connection

mRS

protected java.sql.ResultSet mRS
result set

mColumnNames

protected java.util.List mColumnNames
column names in natural order

mStatement

protected java.sql.Statement mStatement
wrapped statement
Constructor Detail

PooledStatement

protected PooledStatement(DBConnection inDBConnection,
                          java.sql.Statement inStatement)
builds a new PooledStatement
Parameters:
inDBConnection - database connection
inStatement - wrapped Statement
Method Detail

query

public RowIterator query(java.lang.String inQuery)
                  throws java.sql.SQLException
gets the resultset for this statement
Parameters:
inQuery - SQL query
Returns:
resulting RowIterator
Throws:
java.sql.SQLException - thrown by the database engine

query

public RowIterator query(java.lang.String inQuery,
                         Entity inResultEntity)
                  throws java.sql.SQLException
gets the resultset for this statement, specifying the entity the results belong to
Parameters:
inQuery - SQL query
inResultEntity - entity
Returns:
the resulting RowIterator
Throws:
java.sql.SQLException - thrown by the database engine

fetch

public java.lang.Object fetch(java.lang.String inQuery)
                       throws java.sql.SQLException
fetch a single row
Parameters:
inQuery - SQL query
Returns:
fetched row
Throws:
java.sql.SQLException - thrown by the database engine

fetch

public java.lang.Object fetch(java.lang.String inQuery,
                              Entity inResultEntity)
                       throws java.sql.SQLException
fetch a single row, specyfing the entity it belongs to
Parameters:
inQuery - SQL query
inResultEntity - entity
Returns:
the fetched Instance
Throws:
java.sql.SQLException - thrown by the database engine

get

public java.lang.Object get(java.lang.Object key)
                     throws java.sql.SQLException
get specified column as an object
Specified by:
get in interface DataAccessor
Parameters:
key - column
Returns:
object value
Throws:
java.sql.SQLException - thrown by the database engine

evaluate

public java.lang.Object evaluate(java.lang.String inQuery)
                          throws java.sql.SQLException
evaluates the SQL query as a scalar
Parameters:
inQuery - SQL query
Returns:
found scalar
Throws:
java.sql.SQLException - thrown by the database engine

update

public int update(java.lang.String inQuery)
           throws java.sql.SQLException
issues the update contained in the query
Parameters:
inQuery - SQL query
Returns:
number of affected rows
Throws:
java.sql.SQLException - thrown by the database engine

close

public void close()
           throws java.sql.SQLException
close thos statement
Overrides:
close in class Pooled
Throws:
java.sql.SQLException - thrown by the database engine

notifyOver

public void notifyOver()
notify this statement is no more used and can be recycled
Overrides:
notifyOver in class Pooled

getLastInsertID

public long getLastInsertID()
                     throws java.sql.SQLException
gets the last insert id
Returns:
last insert id
Throws:
java.sql.SQLException - thrown by the database engine


ooOoo