com.intersys.objects
Class CacheDatabase

java.lang.Object
  extended bycom.intersys.objects.CacheDatabase

public class CacheDatabase
extends Object

This class is used to establish a connection to the Cache server for Java clients.
Connection parameters depend on parameters passed to method getConnection and values for a number of system properties.
The following properties may be set by users:


The following properties will affect system behaviour but should be set only by Intersystems support representatives:


Field Summary
static int ANT
           
static int DEFAULT
           
static int LAZY
           
static int NONE
           
 
Constructor Summary
CacheDatabase()
           
 
Method Summary
static Database getDatabase(Connection connection)
          Attempts to establish a connection to the Cache server using existing JDBC connection to it.
static Database getDatabase(String connectionString)
          Attempts to establish a connection to the Cache server at given URL for user "_SYSTEM" with password "sys".
static Database getDatabase(String connectionString, String user, String password)
          Attempts to establish a connection to the Cache server at given URL.
static Database getDatabase(String connectionString, String user, String password, int cacheType)
          Attempts to establish a connection to the Cache server at given URL.
static Database getDatabase(String connectionString, String user, String password, int cacheType, boolean bUseStatistics)
          Attempts to establish a connection to the Cache server at given URL.
static Database getLightDatabase(Connection connection)
          Attempts to establish a "Light" connection to the Cache server using existing JDBC connection to it.
static Database getLightDatabase(String connectionString, String user, String password)
          Attempts to establish a "Light" connection to the Cache server at given URL.
static int getNumberOfProfiles()
          Returns number of segments to gather profiling information.
static Database getReadOnlyDatabase(Connection connection)
           
static Database getReadOnlyDatabase(String url, String user, String password)
           
static void setNumberOfProfiles(int n)
          Sets number of segments to gather profiling information.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final int DEFAULT
See Also:
Constant Field Values

NONE

public static final int NONE
See Also:
Constant Field Values

ANT

public static final int ANT
See Also:
Constant Field Values

LAZY

public static final int LAZY
See Also:
Constant Field Values
Constructor Detail

CacheDatabase

public CacheDatabase()
Method Detail

getDatabase

public static Database getDatabase(String connectionString,
                                   String user,
                                   String password)
                            throws CacheException
Attempts to establish a connection to the Cache server at given URL. Parameters for cache type and statistics usage determined from system properties or defaults.
Cache type is determined from the value of system property com.intersys.cache.type. Possible values for this property are: If the property com.intersys.cache.type is not defined or has value default system default type is assumed, currently ant Whether to gather statistics for cache usage is determined from the value of system property com.intersys.cache.statistics. Possible values for this property are: If the property com.intersys.cache.statistics is not defined statistics is not gathered.

Parameters:
connectionString - connection string
old url format:
"cn_iptcp:127.0.0.1[1972]:USER"
new url format:
"jdbc:Cache://127.0.0.1:1972/USER"
user - User name for Cache database. If null user "_SYSTEM" is assumed.
password - Password for user of Cache. If null password "SYS" is used.
Returns:
connection to server represented as an instance of com.intersys.objects.Database
Throws:
CacheException - if connection can not be esatblished for any reason.
See Also:
Database.printStatistics(java.io.PrintStream), Database.printStatistics()

getDatabase

public static Database getDatabase(String connectionString)
                            throws CacheException
Attempts to establish a connection to the Cache server at given URL for user "_SYSTEM" with password "sys". Parameters for cache type and statistics usage determined from system properties or defaults.
Cache type is determined from the value of system property com.intersys.cache.type. Possible values for this property are: If the property com.intersys.cache.type is not defined or has value default system default type is assumed, currently ant Whether to gather statistics for cache usage is determined from the value of system property com.intersys.cache.statistics. Possible values for this property are: If the property com.intersys.cache.statistics is not defined statistics is not gathered.

Parameters:
connectionString - connection string
old url format:
"cn_iptcp:127.0.0.1[1972]:USER"
new url format:
"jdbc:Cache://127.0.0.1:1972/USER"
Returns:
connection to server represented as an instance of com.intersys.objects.Database
Throws:
CacheException - if connection can not be esatblished for any reason.
See Also:
Database.printStatistics(java.io.PrintStream), Database.printStatistics()

getDatabase

public static Database getDatabase(Connection connection)
                            throws CacheException
Attempts to establish a connection to the Cache server using existing JDBC connection to it. Parameters for cache type and statistics usage determined from system properties or defaults.
Cache type is determined from the value of system property com.intersys.cache.type. Possible values for this property are: If the property com.intersys.cache.type is not defined or has value default system default type is assumed, currently ant Whether to gather statistics for cache usage is determined from the value of system property com.intersys.cache.statistics. Possible values for this property are: If the property com.intersys.cache.statistics is not defined statistics is not gathered.

Parameters:
connection - JDBC connection represented as java.sql.Connection object.
Returns:
connection to server represented as an instance of com.intersys.objects.Database
Throws:
CacheException - if connection can not be esatblished for any reason.
See Also:
Database.printStatistics(java.io.PrintStream), Database.printStatistics()

getDatabase

public static Database getDatabase(String connectionString,
                                   String user,
                                   String password,
                                   int cacheType,
                                   boolean bUseStatistics)
                            throws CacheException
Attempts to establish a connection to the Cache server at given URL.

Parameters:
connectionString - connection string
old url format:
"cn_iptcp:127.0.0.1[1972]:USER"
new url format:
"jdbc:Cache://127.0.0.1:1972/USER"
cacheType - type of internal cache. Possible values:
  • com.intersys.objects.CacheDatabase.NONE: no client side caching, all requests always go directly to Cache database.
  • com.intersys.objects.CacheDatabase.ANT: normal caching.
  • com.intersys.objects.CacheDatabase.LAZY: lazy caching, not yet implemented option.
  • com.intersys.objects.CacheDatabase.DEFAULT (or any negative value): cache type is determined from system properties.

If cache type is default it is determined from the value of system property com.intersys.cache.type. Possible values for this property are:
  • ant: normal caching
  • lazy: lazy caching
  • none: no client side caching, all requests always go directly to Cache database.
If the property com.intersys.cache.type is not defined or has value default system default type is assumed, currently ant
bUseStatistics - if true, then statistics for cache usage will be gathered and can be printed later by calling method printStatistics
user - User name for Cache database. If null user "_SYSTEM" is assumed.
password - Password for user of Cache. If null password "SYS" is used.
Returns:
connection to server represented as an instance of com.intersys.objects.Database
Throws:
CacheException - if connection can not be esatblished for any reason.
See Also:
Database.printStatistics(java.io.PrintStream), Database.printStatistics()

getDatabase

public static Database getDatabase(String connectionString,
                                   String user,
                                   String password,
                                   int cacheType)
                            throws CacheException
Attempts to establish a connection to the Cache server at given URL. Whether to gather statistics for cache usage is determined from the value of system property com.intersys.cache.statistics. Possible values for this property are: If the property com.intersys.cache.statistics is not defined statistics is not gathered.

Parameters:
connectionString - connection string
old url format:
"cn_iptcp:127.0.0.1[1972]:USER"
new url format:
"jdbc:Cache://127.0.0.1:1972/USER"
cacheType - type of internal cache. Possible values:
  • com.intersys.objects.CacheDatabase.NONE: no client side caching, all requests always go directly to Cache database.
  • com.intersys.objects.CacheDatabase.ANT: normal caching.
  • com.intersys.objects.CacheDatabase.LAZY: lazy caching, not yet implemented option.
  • com.intersys.objects.CacheDatabase.DEFAULT (or any negative value): cache type is determined from system properties.

If cache type is default it is determined from the value of system property com.intersys.cache.type. Possible values for this property are:
  • ant: normal caching
  • lazy: lazy caching
  • none: no client side caching, all requests always go directly to Cache database.
If the property com.intersys.cache.type is not defined or has value default system default type is assumed, currently ant
user - User name for Cache database. If null user "_SYSTEM" is assumed.
password - Password for user of Cache. If null password "SYS" is used.
Returns:
connection to server represented as an instance of com.intersys.objects.Database
Throws:
CacheException - if connection can not be esatblished for any reason.
See Also:
Database.printStatistics(java.io.PrintStream), Database.printStatistics()

getLightDatabase

public static Database getLightDatabase(String connectionString,
                                        String user,
                                        String password)
                                 throws CacheException
Attempts to establish a "Light" connection to the Cache server at given URL. This method is faster than "normal" connection but has significan limitations:

Parameters:
connectionString - connection string in URL format, for example:
"jdbc:Cache://localhost:1972/USER"
user - User name for Cache database. If null user "_SYSTEM" is assumed.
password - Password for user of Cache. If null password "SYS" is used.
Returns:
connection to server represented as an instance of com.intersys.objects.Database
Throws:
CacheException - if connection can not be esatblished for any reason.

getLightDatabase

public static Database getLightDatabase(Connection connection)
                                 throws CacheException
Attempts to establish a "Light" connection to the Cache server using existing JDBC connection to it. This method is faster than "normal" connection but has significan limitations:

Parameters:
connection - JDBC connection represented as java.sql.Connection object.
Returns:
connection to server represented as an instance of com.intersys.objects.Database
Throws:
CacheException - if connection can not be esatblished for any reason.

getReadOnlyDatabase

public static Database getReadOnlyDatabase(Connection connection)
                                    throws CacheException
Throws:
CacheException

getReadOnlyDatabase

public static Database getReadOnlyDatabase(String url,
                                           String user,
                                           String password)
                                    throws CacheException
Throws:
CacheException

setNumberOfProfiles

public static void setNumberOfProfiles(int n)
Sets number of segments to gather profiling information. For each segment cumulative server time and number of server calls is calculated. For this method to have effect it should be called before creating database object. Note, that value of system property com.intersys.profile.segments takes precedence over value set using this method.

Parameters:
n - number of profiling segments.
See Also:
Database.getNumberOfServerCalls(int), Database.getServerTime(int), Database.setProfileOn(int), Database.setProfileOn(int), getNumberOfProfiles()

getNumberOfProfiles

public static int getNumberOfProfiles()
Returns number of segments to gather profiling information. For each segment cumulative server time and number of server calls is calculated.

Returns:
Number of profiling segments.
See Also:
Database.getNumberOfServerCalls(int), Database.getServerTime(int), Database.setProfileOn(int), Database.setProfileOn(int), getNumberOfProfiles()