com.intersys.jdbc
Class CacheDataSource

java.lang.Object
  extended bycom.intersys.jdbc.CacheDataSource
All Implemented Interfaces:
javax.sql.DataSource
Direct Known Subclasses:
CacheConnectionPoolDataSource

public class CacheDataSource
extends Object
implements javax.sql.DataSource

CacheDataSource object is an implementation of DataSource interface. In addition to the apis defined by the interface, this class also includes a number of Cache specific apis that can be used to set up the DataSource properties (setters) or get the information about the DataSource object properties (getters). In order to be able to connect, at least server name and database name properties must be defined, either by using the corresponding setters, or by supplying a valid url (same as what would be used when connecting via Driver class). Port number is optional, and defaults to 1972. Username and Password can be set via the setters, or alternatively, can be supplied via the getConnection api. Description and DataSource name are completely optional and are not used by CacheDataSource object in order to connect. Logging can be enabled by setting the LogWritter, and Login Timeout set by calling the corresponding setter (both are optional). Cache also provides a way to set the TCP nodelay flag. Toggling this flag can affect the performance of this application. If not set, it defaults to true. Event Class is a mechanism specific to Cache JDBC. It is completely optional, and the vast majority of applications will not need this feature. See setEventClass for more info on Event Class objects.


Constructor Summary
CacheDataSource()
           
 
Method Summary
 Connection getConnection()
           
 Connection getConnection(String usr, String pwd)
           
 int getConnectionSecurityLevel()
          Returns an int representing current Connection Security Level setting.
 String getDatabaseName()
          Returns a String representing the current database (Cache Namespace) name.
 String getDataSourceName()
          Returns a String representing the current Data Source name.
 String getDescription()
          Returns a String representing the current description.
 String getEventClass()
          Returns a String representing an Event Class object.
 int getLoginTimeout()
           
 PrintWriter getLogWriter()
           
 boolean getNodelay()
          Returns a boolean representing a current nodelay flag setting.
 String getPassword()
          Returns a String representing the current password.
 int getPortNumber()
          Returns an int representing the current port number.
 String getServerName()
          Returns a String representing the current server name.
 String getServicePrincipalName()
          Returns a String representing current Service Principal Name setting.
 String getURL()
          Returns a String representing a current URL for this DataSource object.
 String getUser()
          Returns a String representing the current username.
 void setConnectionSecurityLevel(int level)
          Sets the Connection Security Level for this DataSource object.
 void setDatabaseName(String databaseName)
          Sets Database (Cache Namespace) name for this DataSource object.
 void setDataSourceName(String dataSourceName)
          Sets Data Source name for this DataSource object.
 void setDescription(String desc)
          Sets description for this DataSource object.
 void setEventClass(String eventClassName)
          Sets the Event Class for this DataSource object.
 void setLoginTimeout(int seconds)
           
 void setLogWriter(PrintWriter out)
           
 void setNodelay(boolean noDelay)
          Sets the noDelay flag for this DataSource object.
 void setPassword(String pwd)
          Sets the password for this DataSource object.
 void setPortNumber(int portNumber)
          Sets the port number for this DataSource object
 void setServerName(String serverName)
          Sets the server name for this DataSource object.
 void setServicePrincipalName(String name)
          Sets the Service Principal Name for this DataSource object.
 void setURL(String u)
          Sets the url for this DataSource object.
 void setUser(String username)
          Sets the username for this DataSource object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheDataSource

public CacheDataSource()
Method Detail

getConnection

public Connection getConnection()
                         throws SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Throws:
SQLException

getConnection

public Connection getConnection(String usr,
                                String pwd)
                         throws SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Throws:
SQLException

getLogWriter

public PrintWriter getLogWriter()
Specified by:
getLogWriter in interface javax.sql.DataSource

setLogWriter

public void setLogWriter(PrintWriter out)
Specified by:
setLogWriter in interface javax.sql.DataSource

setLoginTimeout

public void setLoginTimeout(int seconds)
Specified by:
setLoginTimeout in interface javax.sql.DataSource

getLoginTimeout

public int getLoginTimeout()
Specified by:
getLoginTimeout in interface javax.sql.DataSource

setDatabaseName

public void setDatabaseName(String databaseName)
Sets Database (Cache Namespace) name for this DataSource object.

Parameters:
databaseName - database (Cache namespace) name

getDatabaseName

public String getDatabaseName()
Returns a String representing the current database (Cache Namespace) name.

Returns:
database (Cache Namespace) name

setDataSourceName

public void setDataSourceName(String dataSourceName)
Sets Data Source name for this DataSource object.

Parameters:
dataSourceName - DataSource name

getDataSourceName

public String getDataSourceName()
Returns a String representing the current Data Source name.

Returns:
DataSource name

setDescription

public void setDescription(String desc)
Sets description for this DataSource object.

Parameters:
desc - DataSource description

getDescription

public String getDescription()
Returns a String representing the current description.

Returns:
description

setPassword

public void setPassword(String pwd)
Sets the password for this DataSource object.

Parameters:
pwd - password

getPassword

public String getPassword()
Returns a String representing the current password.

Returns:
password

setPortNumber

public void setPortNumber(int portNumber)
Sets the port number for this DataSource object

Parameters:
portNumber - port number

getPortNumber

public int getPortNumber()
Returns an int representing the current port number.

Returns:
port number

setServerName

public void setServerName(String serverName)
Sets the server name for this DataSource object.

Parameters:
serverName - server name

getServerName

public String getServerName()
Returns a String representing the current server name.

Returns:
server name

setUser

public void setUser(String username)
Sets the username for this DataSource object.

Parameters:
username - username

getUser

public String getUser()
Returns a String representing the current username.

Returns:
username

setEventClass

public void setEventClass(String eventClassName)
Sets the Event Class for this DataSource object. Cache JDBC server will dispatch to methods implemented in a class when a transaction is about to be committed and when a transaction is about to be rolled back. The class in which these methods are implemented is referred to as the 'event class'. If an event class is specified during login then the JDBC server will dispatch to %OnTranCommit just prior to committing the current transaction and will dispatch to %OnTranRollback just prior to rolling back (aborting) the current transaction. User event classes should extend %ServerEvent. The methods do not return any values and cannot abort the current transaction.

Parameters:
eventClassName - event class name

getEventClass

public String getEventClass()
Returns a String representing an Event Class object.

Returns:
event class

setURL

public void setURL(String u)
            throws SQLException
Sets the url for this DataSource object.

Parameters:
u - url
Throws:
SQLException

getURL

public String getURL()
Returns a String representing a current URL for this DataSource object.

Returns:
url

setNodelay

public void setNodelay(boolean noDelay)
Sets the noDelay flag for this DataSource object.

Parameters:
noDelay - nodelay flag

getNodelay

public boolean getNodelay()
Returns a boolean representing a current nodelay flag setting.

Returns:
nodelay flag

setServicePrincipalName

public void setServicePrincipalName(String name)
Sets the Service Principal Name for this DataSource object.

Parameters:
name - principal name

getServicePrincipalName

public String getServicePrincipalName()
Returns a String representing current Service Principal Name setting.

Returns:
principal name

setConnectionSecurityLevel

public void setConnectionSecurityLevel(int level)
Sets the Connection Security Level for this DataSource object.

Parameters:
level - security level

getConnectionSecurityLevel

public int getConnectionSecurityLevel()
Returns an int representing current Connection Security Level setting.

Returns:
security level