i-net Clear Reports

com.inet.report.cache
Class ExternalDBCache

java.lang.Object
  extended by com.inet.report.cache.Cache
      extended by com.inet.report.cache.ExternalDBCache

public class ExternalDBCache
extends Cache

This class implements a database cache without a connection factory. This means that the connections have to be set from an external program. These methods can be use together with the cache type "External Database Cache", only.

Since:
7.5
See Also:
Cache.TYPE_EXTERNAL_DATABASE

Field Summary
 
Fields inherited from class com.inet.report.cache.Cache
TYPE_DATABASE, TYPE_EXTERNAL_DATABASE, TYPE_HARDDISK, TYPE_MEMORY
 
Method Summary
static void addConnection(java.sql.Connection conn)
          Adds a connection to the pool for the External Database Cache.
static void checkConnections(java.lang.String jndiName)
          Checks whether the database pool for caching has enough connections.
static boolean isConnectionNeeded()
          Checks whether the External Database Cache need more connections.
 
Methods inherited from class com.inet.report.cache.Cache
addEngine, createKey, createKey, createKey, delete, delete, exists, getCache, getEngineFactory, getFailureCause, getKey, getKey, getKey, getPageAndWait, getPageAndWait, getPageCountAndWait, getPageCountAndWait, getReports, getTotalPageSizeAndWait, getTotalPageSizeAndWait, getType, isFailedReport, isFinishWrittenToStore, isFinished, isPageLimitExceeded, isScheduleReport, isTypeSchedulerCache, lock, resetCacheTimeout, setEngineFactory, setSchedule, unlock
 

Method Detail

isConnectionNeeded

public static boolean isConnectionNeeded()
                                  throws ReportException
Checks whether the External Database Cache need more connections. The typical use is:
 while(ExternalDBCache.isConnectionNeeded()){
     Connection conn = myConnectionFactory();
     ExternalDBCache.addConnection(conn);
 }

Returns:
true if the cache need more connections
Throws:
ReportException - If the current cache type ID is not ExternalDBCache
Since:
7.5
See Also:
addConnection(java.sql.Connection), Cache.TYPE_EXTERNAL_DATABASE

addConnection

public static void addConnection(java.sql.Connection conn)
                          throws ReportException
Adds a connection to the pool for the External Database Cache. This connection should be a long-term connection, open as long as possible. It should be accessible from another thread.

Parameters:
conn - a new JDBC connection
Throws:
ReportException - If the current cache type ID is not ExternalDBCache
Since:
7.5
See Also:
isConnectionNeeded(), Cache.TYPE_EXTERNAL_DATABASE

checkConnections

public static void checkConnections(java.lang.String jndiName)
                             throws ReportException
Checks whether the database pool for caching has enough connections. If not, then it creates a new connection for the specified JNDI name and add it to the pool. If you use the External Database Cache together with JNDI then you should call this method before rendering a report.
This can be done in the servlet method service(), for example.

Parameters:
jndiName - the JNDI name of the datasource that the cache should use.
Throws:
ReportException - If the current cache type ID is not ExternalDBCache
Since:
7.5
See Also:
Cache.TYPE_EXTERNAL_DATABASE

i-net Clear Reports

Copyright © 1999-2011 by i-net software GmbH