|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.client.am.stmtcache.JDBCStatementCache
public final class JDBCStatementCache
A cache for JDBC statement objects.
The entries in the cache contains objects implementing the
java.sql.PreparedStatement
interface, and they are inserted with
a key object implementing the interface StatementKey
. The cached
objects can be either java.sql.PreparedStatement
or
java.sql.CallableStatement
. These two should be separated by
using different types of keys.
The cache only contains free statement objects, and on a successful request
for a cached statement the statement is removed from the cache. The cache is
not intended to hold duplicate statements. The physical prepared statement
should be (re-)inserted into the cache when close
is called on
the logical prepared statement using it.
There is a maximum number of cached statements associated with the cache. If this number is exceeded, the oldest entry will be thrown out. One can always throw out an entry, because the fact that it is in the cache means it is free and not in use.
Nested Class Summary | |
---|---|
private static class |
JDBCStatementCache.BoundedLinkedHashMap
A LinkedHashMap with an upper bound on the number of entries. |
Field Summary | |
---|---|
private java.util.LinkedHashMap |
statements
Structure holding the cached prepared statement objects. |
Constructor Summary | |
---|---|
JDBCStatementCache(int maxSize)
Creates a new, empty JDBC statement cache. |
Method Summary | |
---|---|
boolean |
cacheStatement(StatementKey statementKey,
java.sql.PreparedStatement ps)
Cache the prepared statement if it does not already exist. |
java.sql.PreparedStatement |
getCached(StatementKey statementKey)
Retrieves a cached prepared statement if one exists. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final java.util.LinkedHashMap statements
Constructor Detail |
---|
public JDBCStatementCache(int maxSize)
maxSize
- maximum number of statements in the cache
java.lang.IllegalArgumentException
- if maxSize
is less than oneMethod Detail |
---|
public java.sql.PreparedStatement getCached(StatementKey statementKey)
statementKey
- key for the prepared statement to look up
null
otherwise.public boolean cacheStatement(StatementKey statementKey, java.sql.PreparedStatement ps)
statementKey
- key to insert prepared statement withps
- prepared statement to cache
true
if added to the cache, false
if
not.
|
Built on Thu 2010-12-23 20:49:13+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |