velosurf.sql
Class StatementPool

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

public class StatementPool
extends java.lang.Object
implements Pool

This class is a pool of PooledStatements.

Author:
Claude Brisson

Field Summary
private  boolean checkConnections
          do we need to check connections?
private  long checkInterval
          minimal check interval
private  java.lang.Thread checkTimeoutThread
          timeout checking thread.
private  ConnectionPool connectionPool
          Connection pool.
private  int count
          number of statements.
private static int maxStatements
          maximum number of statements.
private  boolean running
          is the thread running?
private  java.util.List<PooledSimpleStatement> statements
          statements.
 
Constructor Summary
protected StatementPool(ConnectionPool connectionPool, boolean checkConnections, long checkInterval)
          build a new pool.
 
Method Summary
 void clear()
          close all statements.
private  void dropConnection(java.sql.Connection connection)
           
protected  void finalize()
          close statements on exit.
 PooledSimpleStatement getStatement()
          get a valid statement.
 int[] getUsageStats()
          debug - two ints long array containing nb of statements in use and total nb of statements.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionPool

private ConnectionPool connectionPool
Connection pool.


count

private int count
number of statements.


statements

private java.util.List<PooledSimpleStatement> statements
statements.


checkTimeoutThread

private java.lang.Thread checkTimeoutThread
timeout checking thread.


running

private boolean running
is the thread running?


checkConnections

private boolean checkConnections
do we need to check connections?


checkInterval

private long checkInterval
minimal check interval


maxStatements

private static final int maxStatements
maximum number of statements.

See Also:
Constant Field Values
Constructor Detail

StatementPool

protected StatementPool(ConnectionPool connectionPool,
                        boolean checkConnections,
                        long checkInterval)
build a new pool.

Parameters:
connectionPool - connection pool
Method Detail

getStatement

public PooledSimpleStatement getStatement()
                                   throws java.sql.SQLException
get a valid statement.

Returns:
a valid statement
Throws:
java.sql.SQLException - thrown by the database engine

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

private void dropConnection(java.sql.Connection connection)

finalize

protected void finalize()
close statements on exit.

Overrides:
finalize in class java.lang.Object


~ooOoo~