velosurf.sql
Class PooledSimpleStatement

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

public class PooledSimpleStatement
extends PooledStatement

this class encapsulates a jdbc Statement.

Author:
Claude Brisson

Field Summary
private  java.sql.Statement statement
          wrapped statement.
 
Fields inherited from class velosurf.sql.PooledStatement
columnNames, connection, resultSet
 
Constructor Summary
PooledSimpleStatement(ConnectionWrapper connection, java.sql.Statement statement)
          build a new PooledStatement.
 
Method Summary
 void close()
          close this statement.
 java.lang.Object evaluate(java.lang.String query)
          evaluates the SQL query as a scalar.
 java.lang.Object fetch(java.lang.String query)
          fetch a single row.
 java.lang.Object fetch(java.lang.String query, Entity resultEntity)
          fetch a single row, specyfing the entity it belongs to.
 java.lang.Object get(java.lang.Object key)
          get specified column as an object.
 ConnectionWrapper getConnection()
          get statement's Connection.
 long getLastInsertID()
          gets the last insert id.
 java.util.Set<java.lang.String> keySet()
          Get keys set.
 void notifyOver()
          notify this statement is no more used and can be recycled.
 RowIterator query(java.lang.String query)
          get the resultset for this statement.
 RowIterator query(java.lang.String query, Entity resultEntity)
          get the resultset for this statement, specifying the entity the results belong to.
 int update(java.lang.String query)
          issue the update contained in the query.
 
Methods inherited from class velosurf.sql.PooledStatement
getTagTime, isInUse, isValid, notifyInUse, resetTagTime, setInvalid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statement

private java.sql.Statement statement
wrapped statement.

Constructor Detail

PooledSimpleStatement

public PooledSimpleStatement(ConnectionWrapper connection,
                             java.sql.Statement statement)
build a new PooledStatement.

Parameters:
connection - database connection
statement - wrapped Statement
Method Detail

query

public RowIterator query(java.lang.String query)
                  throws java.sql.SQLException
get the resultset for this statement.

Parameters:
query - SQL query
Returns:
resulting RowIterator
Throws:
java.sql.SQLException - thrown by the database engine

query

public RowIterator query(java.lang.String query,
                         Entity resultEntity)
                  throws java.sql.SQLException
get the resultset for this statement, specifying the entity the results belong to.

Parameters:
query - SQL query
resultEntity - entity
Returns:
the resulting RowIterator
Throws:
java.sql.SQLException - thrown by the database engine

fetch

public java.lang.Object fetch(java.lang.String query)
                       throws java.sql.SQLException
fetch a single row.

Parameters:
query - SQL query
Returns:
fetched row
Throws:
java.sql.SQLException - thrown by the database engine

fetch

public java.lang.Object fetch(java.lang.String query,
                              Entity resultEntity)
                       throws java.sql.SQLException
fetch a single row, specyfing the entity it belongs to.

Parameters:
query - SQL query
resultEntity - 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.

Parameters:
key - column
Returns:
object value
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.

Returns:
keys set
Throws:
java.sql.SQLException

evaluate

public java.lang.Object evaluate(java.lang.String query)
                          throws java.sql.SQLException
evaluates the SQL query as a scalar.

Parameters:
query - SQL query
Returns:
found scalar
Throws:
java.sql.SQLException - thrown by the database engine

update

public int update(java.lang.String query)
           throws java.sql.SQLException
issue the update contained in the query.

Parameters:
query - 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 this statement.

Specified by:
close in class PooledStatement
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 PooledStatement

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

getConnection

public ConnectionWrapper getConnection()
get statement's Connection.

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


~ooOoo~