velosurf.sql
Class PreparedStatementPool

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

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

This class is a pool of PooledPreparedStatements

Author:
Claude Brisson

Field Summary
protected  java.lang.Thread mCheckTimeoutThread
          running thread
protected  ConnectionPool mConnectionPool
          connection pool
protected  int mCount
          statements count
protected  boolean mRunning
          true if running
protected  HashMultiMap mStatementsMap
          map queries -> statements
protected static long sCheckDelay
          check delay
protected static int sMaxStatements
          max number of statements
protected static long sTimeout
          after this timeout, statements are recycled even if not closed
 
Constructor Summary
protected PreparedStatementPool(ConnectionPool inConnectionPool)
          builds a new pool
 
Method Summary
 void clear()
          close all statements
protected  void dropConnection(java.sql.Connection connection)
           
protected  void finalize()
          clear statements on exit
 PooledPreparedStatement getPreparedStatement(java.lang.String inQuery)
          gets a PooledPreparedStatement associated with this query
protected  int[] getUsageStats()
          debug - get usage statistics
 void run()
          cycle through statements to check and recycle them
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mConnectionPool

protected ConnectionPool mConnectionPool
connection pool


mCount

protected int mCount
statements count


mStatementsMap

protected HashMultiMap mStatementsMap
map queries -> statements


mCheckTimeoutThread

protected java.lang.Thread mCheckTimeoutThread
running thread


mRunning

protected boolean mRunning
true if running


sCheckDelay

protected static final long sCheckDelay
check delay

See Also:
Constant Field Values

sTimeout

protected static final long sTimeout
after this timeout, statements are recycled even if not closed

See Also:
Constant Field Values

sMaxStatements

protected static final int sMaxStatements
max number of statements

See Also:
Constant Field Values
Constructor Detail

PreparedStatementPool

protected PreparedStatementPool(ConnectionPool inConnectionPool)
builds a new pool

Parameters:
inConnectionPool - connection pool
Method Detail

getPreparedStatement

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

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

run

public void run()
cycle through statements to check and recycle them

Specified by:
run in interface java.lang.Runnable

clear

public void clear()
close all statements


dropConnection

protected void dropConnection(java.sql.Connection connection)

finalize

protected void finalize()
clear statements on exit

Overrides:
finalize in class java.lang.Object

getUsageStats

protected int[] getUsageStats()
debug - get usage statistics

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


~ooOoo~