velosurf.sql
Class StatementPool

java.lang.Object
  |
  +--velosurf.sql.StatementPool
All Implemented Interfaces:
Pool, java.lang.Runnable

public class StatementPool
extends java.lang.Object
implements java.lang.Runnable, Pool

This class is a pool of PooledStatements


Field Summary
protected  java.lang.Thread mCheckTimeoutThread
          timeout checking thread
protected  int mCount
          number of statements
protected  DBConnection mDBConnection
          database connection
protected  boolean mRunning
          is the thread running ?
protected  java.util.Vector mStatements
          statements
protected static long sCheckDelay
          delay between checks
protected static int sMaxStatements
          maximum number of statements
protected static long sTimeout
          timeout on which statements are automatically recycled if not used
 
Constructor Summary
StatementPool(DBConnection inDBConnection)
          builds a new pool
 
Method Summary
 void clear()
          close all statements
protected  void finalize()
          close statements on exit
 PooledStatement getStatement()
          gets a valid statement
 PooledStatement getTransactionStatement()
          get a statement to be used in a transaction
 int[] getUsageStats()
          debug - two ints long array containing nb of statements in use and total nb of statements
 void run()
          run the loop of statements checking and recycling
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

mDBConnection

protected DBConnection mDBConnection
database connection

mCount

protected int mCount
number of statements

mStatements

protected java.util.Vector mStatements
statements

mCheckTimeoutThread

protected java.lang.Thread mCheckTimeoutThread
timeout checking thread

mRunning

protected boolean mRunning
is the thread running ?

sCheckDelay

protected static long sCheckDelay
delay between checks

sTimeout

protected static long sTimeout
timeout on which statements are automatically recycled if not used

sMaxStatements

protected static int sMaxStatements
maximum number of statements
Constructor Detail

StatementPool

public StatementPool(DBConnection inDBConnection)
builds a new pool
Parameters:
inDBConnection - database connection
Method Detail

getStatement

public PooledStatement getStatement()
                             throws java.sql.SQLException
gets a valid statement
Returns:
a valid statement
Throws:
java.sql.SQLException - thrown by the database engine

getTransactionStatement

public PooledStatement getTransactionStatement()
                                        throws java.sql.SQLException
get a statement to be used in a transaction
Returns:
a valid statement
Throws:
java.sql.SQLException - thrown by the database engine

run

public void run()
run the loop of statements checking and recycling
Specified by:
run in interface java.lang.Runnable

getUsageStats

public int[] getUsageStats()
debug - two ints long array containing nb of statements in use and total nb of statements
Returns:
2 integers long array

clear

public void clear()
close all statements

finalize

protected void finalize()
close statements on exit
Overrides:
finalize in class java.lang.Object


ooOoo