SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

com.solarmetric.rd.jdbc
Class PreparedStatementCache

java.lang.Object
  |
  +--com.solarmetric.rd.jdbc.PreparedStatementCache

public class PreparedStatementCache
extends java.lang.Object

Implements a cache mapping a SQL string, PreparedStatementCache.CacheAwareConnection pair to a PreparedStatement containing the same SQL using the same connection. Use the newCacheAwareConnection(java.sql.Connection) to create a connection wrapper that will automatically use this cache.

The cache uses a LRU algorithm to kick out old prepared statements when the given max size is exceeded.


Nested Class Summary
 class PreparedStatementCache.CacheAwareConnection
          Connection wrapper class that uses the cache to prepare statements when possible.
 
Constructor Summary
PreparedStatementCache()
          Default constructor.
PreparedStatementCache(int maxSize)
          Constructor.
 
Method Summary
 int getMaxSize()
          Return the maximum size of the cache.
 PreparedStatementCache.CacheAwareConnection newCacheAwareConnection(java.sql.Connection conn)
          Return a PreparedStatementCache.CacheAwareConnection wrapper that is aware of this cache and will use it when possible.
 void setMaxSize(int maxSize)
          Set the maximum size of the cache.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PreparedStatementCache

public PreparedStatementCache()
Default constructor. Create a cache with a default maximum size of 50.


PreparedStatementCache

public PreparedStatementCache(int maxSize)
Constructor.

Parameters:
maxSize - the size of the prepared statement cache
Method Detail

getMaxSize

public int getMaxSize()
Return the maximum size of the cache.


setMaxSize

public void setMaxSize(int maxSize)
Set the maximum size of the cache.


newCacheAwareConnection

public PreparedStatementCache.CacheAwareConnection newCacheAwareConnection(java.sql.Connection conn)
Return a PreparedStatementCache.CacheAwareConnection wrapper that is aware of this cache and will use it when possible.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.