velosurf.sql
Class PreparedStatementPool

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

public class PreparedStatementPool
extends java.lang.Object
implements Pool

This class is a pool of PooledPreparedStatements.

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
          running thread.
private  ConnectionPool connectionPool
          connection pool.
private  int count
          statements count.
private static int maxStatements
          max number of statements.
private  boolean running
          true if running.
private  HashMultiMap statementsMap
          map queries -> statements.
 
Constructor Summary
protected PreparedStatementPool(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()
          clear statements on exit.
 PooledPreparedStatement getPreparedStatement(java.lang.String query)
          get a PooledPreparedStatement associated with this query.
 int[] getUsageStats()
          debug - get usage statistics.
 
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
statements count.


statementsMap

private HashMultiMap statementsMap
map queries -> statements.


checkTimeoutThread

private java.lang.Thread checkTimeoutThread
running thread.


running

private boolean running
true if running.


checkConnections

private boolean checkConnections
do we need to check connections?


checkInterval

private long checkInterval
minimal check interval


maxStatements

private static final int maxStatements
max number of statements.

See Also:
Constant Field Values
Constructor Detail

PreparedStatementPool

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

Parameters:
connectionPool - connection pool
Method Detail

getPreparedStatement

public PooledPreparedStatement getPreparedStatement(java.lang.String query)
                                             throws java.sql.SQLException
get a PooledPreparedStatement associated with this query.

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

clear

public void clear()
close all statements.


dropConnection

private void dropConnection(java.sql.Connection connection)

finalize

protected void finalize()
clear statements on exit.

Overrides:
finalize in class java.lang.Object

getUsageStats

public int[] getUsageStats()
debug - get usage statistics.

Returns:
an int array : [nb of statements in use , total nb of statements]


~ooOoo~