velosurf.sql
Class StatementPool

java.lang.Object
  extended by velosurf.sql.StatementPool
All Implemented Interfaces:
java.lang.Runnable, Pool

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

This class is a pool of PooledStatements

Author:
Claude Brisson

Field Summary
protected static long checkDelay
          delay between checks
protected  java.lang.Thread checkTimeoutThread
          timeout checking thread
protected  ConnectionPool connectionPool
          Connection pool
protected  int count
          number of statements
protected static int maxStatements
          maximum number of statements
protected  boolean running
          is the thread running ?
protected  java.util.List statements
          statements
protected static long timeout
          timeout on which statements are automatically recycled if not used
 
Constructor Summary
StatementPool(ConnectionPool connectionPool)
          builds a new pool
 
Method Summary
 void clear()
          close all statements
protected  void dropConnection(java.sql.Connection connection)
           
protected  void finalize()
          close statements on exit
 PooledStatement getStatement()
          gets a valid statement
 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, toString, wait, wait, wait
 

Field Detail

connectionPool

protected ConnectionPool connectionPool
Connection pool


count

protected int count
number of statements


statements

protected java.util.List statements
statements


checkTimeoutThread

protected java.lang.Thread checkTimeoutThread
timeout checking thread


running

protected boolean running
is the thread running ?


checkDelay

protected static final long checkDelay
delay between checks

See Also:
Constant Field Values

timeout

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

See Also:
Constant Field Values

maxStatements

protected static final int maxStatements
maximum number of statements

See Also:
Constant Field Values
Constructor Detail

StatementPool

public StatementPool(ConnectionPool connectionPool)
builds a new pool

Parameters:
connectionPool - connection pool
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

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


dropConnection

protected void dropConnection(java.sql.Connection connection)

finalize

protected void finalize()
close statements on exit

Overrides:
finalize in class java.lang.Object


~ooOoo~