Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.jtds.jdbc.cache
Interface StatementCache

All Known Implementing Classes:
  ProcedureCache

public interface StatementCache

Interface for a statement cache. Abstraction of the caching mechanism by use of this interface will allow developers to create custom caching schemes that are optimal for their specific applications. Any synchronization required by an implementation should utilize the implementing object for the lock.

There are two types of attributes that the cache is concerned with:

statement key
  `String` generated from the SQL query for which the prepared statement was created, the database name and the parameter types; this key uniquely identifies a server-side preparation of the statement and is used to retrieve the handle of the statement when it needs to be executed
temporary procedure name or `sp_prepare` or `sp_cursorprepare` handle on the server
  One `PreparedStatement` can map to multiple handles, depending on the types of the parameters it is called with (hence the need to be able to map both keys and SQL strings to handles)

The cache can retrieve statement handles using statement keys.

The caching types provided by jTDS should be:

- Arbitrary first un-latched (initial default until other caches are implemented)
- Fast caching (never latches and never releases handles)
- FIFO
- LRU
- No caching
- Touch Count / Most Frequently Used

Version:
  $Id: StatementCache.java,v 1.6 2007/07/11 19:57:06 bheineman Exp $
Author:
  Brian Heineman

Method Summary
`java.lang.Object` | `get(java.lang.String key)` Returns a statement handle associated with the specified key or `null` if the key specified does not have an associated statement handle.
`java.util.Collection` | `getObsoleteHandles(java.util.Collection handles)` Returns a `Collection` of obsolete statement handles that may be released, or `null` if no statement handles are obsolete.
`void` | `put(java.lang.String key, java.lang.Object handle)` Places the specified statement handle in the cache for the given key.
`void` | `remove(java.lang.String key)` Removes a statement key and handle from the cache for the specified key.

Method Detail

### get

    public java.lang.Object get(java.lang.String key)

  Returns a statement handle associated with the specified key or `null` if the key specified does not have an associated statement handle.
  Parameters:
    `key` - the statement key whose associated handle is to be returned
  Returns:
    statement handle

### put

    public void put(java.lang.String key,
                    java.lang.Object handle)

  Places the specified statement handle in the cache for the given key. If a key already exists in the cache, the handle will be overwritten.
  Parameters:
    `key` - the statement key to associated with the handle
    `handle` - the statement handle

### remove

    public void remove(java.lang.String key)

  Removes a statement key and handle from the cache for the specified key.
  Parameters:
    `key` - the statement key whose associated handle is to be removed from the cache

### getObsoleteHandles

    public java.util.Collection getObsoleteHandles(java.util.Collection handles)

  Returns a `Collection` of obsolete statement handles that may be released, or `null` if no statement handles are obsolete.
  Parameters:
    `handles` - the statement handles that are no longer being used
  Returns:
    `Collection` of obsolete statement handles to be removed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Generated on August 22 2007