com.sybase.jdbcx
Interface SybDataSource


public abstract interface SybDataSource
extends Serializable

This interface replaces the functionality of SybDriver.

It should only be used by applications responsible for administering your environment. The interface provides several accessor and mutator methods (following the JavaBeans convention) to configure the DataSource. These standard properties are defined in the JDBC 2.0 standard extension specification on page 12. Note: there is currently no support for roleName.

This interface also provides the setConnectionProperties method which allows users to set jConnect connection properties -- in the same way that they did on the JDBC URL or within client code using DriverManager.getConnection(String, Properties).

Typically, when the object that implements this interface is stored on the name server, it should only be accessed via one of the javax.sql DataSource interfaces. That is, the client shouldn't need to access any of these methods, they are strictly intended to be used to configure DataSources before they are deployed.

This interface is both Referenceable and Serializable so that it can be stored by any number of name servers, and retrieved via JNDI and the SybObjectFactory. However, upon retrieval the following properties will not be restored (they are transient):


Field Summary
static String CONNECTION_PROPERTY
          methods for this attribute are:
getConnectionProperty(String) and setConnectionProperties(Properties).
static String DATA_SOURCE_NAME
          methods for this attribute are:
getDataSourceName() and setDataSourceName(String).
static String DATABASE_NAME
          methods for this attribute are:
getDatabaseName() and setDatabaseName(String).
static String DESCRIPTION
          methods for this attribute are:
getDescription() and setDescription(String).
static String NETWORK_PROTOCOL
          methods for this attribute are:
getNetworkProtocol() and setNetworkProtocol(String).
static String PASSWORD
          methods for this attribute are:
getPassword() and setPassword(String).
static String PORT_NUMBER
          methods for this attribute are:
getPortNumber() and setPortNumber(int).
static String SERVER_NAME
          methods for this attribute are:
getServerName() and setServerName(String).
static String USER
          methods for this attribute are:
getUser() and setUser(String).
 
Method Summary
 DynamicClassLoader getClassLoader(String url, Properties props)
          Return a new class loader which will connect with the specified url and properties.
 Object getConnectionProperty(String prop)
           
 String getDatabaseName()
           
 String getDataSourceName()
           
 Debug getDebug()
          Returns a Debug object for this driver.
 String getDescription()
           
 String getNetworkProtocol()
           
 String getPassword()
           
 int getPortNumber()
           
 String getResourceManagerName()
           
 int getResourceManagerType()
           
 String getServerName()
           
 SybMessageHandler getSybMessageHandler()
          Returns the current message handler object for this driver.
 String getUser()
           
 void setConnectionProperties(Properties props)
          Provided as a replacement for being able to call Driver.getConnection(url, props).
 void setDatabaseName(String newDatabaseName)
           
 void setDataSourceName(String newDataSourceName)
           
 void setDescription(String newDescription)
           
 void setNetworkProtocol(String newProtocol)
           
 void setPassword(String newPassword)
           
 void setPortNumber(int newPortNumber)
           
 void setRemotePassword(String serverName, String password, Properties props)
          Set the remote password in the given Properties object.
 void setResourceManagerName(String newRMName)
          This logical name corresponds to the xa_open call from the XA Specification.
 void setResourceManagerType(int type)
          Inform this datasource that if XAConnections are to be created, that this type of resource manager should be expected. This method is only necessary when the manager is an XA Server 11, and should then be called as setResourceManagerType(SybDataSource.RMTYPE_XA_11)
 void setServerName(String newServerName)
           
 void setSybMessageHandler(SybMessageHandler msgHandler)
          Sets the message handler for this driver.
 void setUser(String newUser)
           
 void setVersion(int version)
          Configures the driver for the desired behavior.
 

Field Detail

DATABASE_NAME

public static final String DATABASE_NAME
methods for this attribute are:
getDatabaseName() and setDatabaseName(String). This represents the name of the database to connect to.

DATA_SOURCE_NAME

public static final String DATA_SOURCE_NAME
methods for this attribute are:
getDataSourceName() and setDataSourceName(String).

DESCRIPTION

public static final String DESCRIPTION
methods for this attribute are:
getDescription() and setDescription(String).

NETWORK_PROTOCOL

public static final String NETWORK_PROTOCOL
methods for this attribute are:
getNetworkProtocol() and setNetworkProtocol(String).

PASSWORD

public static final String PASSWORD
methods for this attribute are:
getPassword() and setPassword(String). This represents the password for the user to use during login if getConnection() is called.

PORT_NUMBER

public static final String PORT_NUMBER
methods for this attribute are:
getPortNumber() and setPortNumber(int). This represents the port number that the server is listening on.

SERVER_NAME

public static final String SERVER_NAME
methods for this attribute are:
getServerName() and setServerName(String). This represents the name of the server (machine) to connect to.

USER

public static final String USER
methods for this attribute are:
getUser() and setUser(String). This represents the name of the user to use during login if getConnection() is called.

CONNECTION_PROPERTY

public static final String CONNECTION_PROPERTY
methods for this attribute are:
getConnectionProperty(String) and setConnectionProperties(Properties). These methods allow users to specify the properties that were historically specified in the JDBC URL or in the Properties object that was passed into DriverManager.getConnection

Method Detail

setVersion

public void setVersion(int version)
                throws SQLException
Configures the driver for the desired behavior. The default version emulation is jConnect2.x.

This method can be called multiple times with different version values. Connections inherit the behavior associated with the version at the time the connection is made. Subsequent changes to the version in the driver have no effect on existing connections.

Parameters:
version - one of the SybDriver.VERSION values
Throws:
SQLException - if the version specified is unrecognized
See Also:
VERSION_2, VERSION_3, VERSION_4, VERSION_LATEST

setSybMessageHandler

public void setSybMessageHandler(SybMessageHandler msgHandler)
Sets the message handler for this driver.
Parameters:
msgHandler - message handler to be called when an error occurs or null to turn off error callbacks

getSybMessageHandler

public SybMessageHandler getSybMessageHandler()
Returns the current message handler object for this driver.
Returns:
the message handler

getDebug

public Debug getDebug()
Returns a Debug object for this driver.
Returns:
a Debug object

setRemotePassword

public void setRemotePassword(String serverName,
                              String password,
                              Properties props)
Set the remote password in the given Properties object.

This method can be used repeatedly to add servername/password combinations to the Properties object you provide. This Properties argument can then be used with the SybDataSource.setConnectionProperties(props) method.

Parameters:
serverName - name of the remote server
password - password at the remote server
props - the Properties in which to store the server/password

getClassLoader

public DynamicClassLoader getClassLoader(String url,
                                         Properties props)
Return a new class loader which will connect with the specified url and properties.
Parameters:
url - the db url used by the class loader to load classes
props - the connection properties used by the loader to connect to the database containing the classes.
Returns:
a new class loader

getServerName

public String getServerName()

setServerName

public void setServerName(String newServerName)

getDatabaseName

public String getDatabaseName()

setDatabaseName

public void setDatabaseName(String newDatabaseName)

getDataSourceName

public String getDataSourceName()

setDataSourceName

public void setDataSourceName(String newDataSourceName)

getDescription

public String getDescription()

setDescription

public void setDescription(String newDescription)

getUser

public String getUser()

setUser

public void setUser(String newUser)

getPassword

public String getPassword()

setPassword

public void setPassword(String newPassword)

getNetworkProtocol

public String getNetworkProtocol()

setNetworkProtocol

public void setNetworkProtocol(String newProtocol)

getPortNumber

public int getPortNumber()

setPortNumber

public void setPortNumber(int newPortNumber)

getConnectionProperty

public Object getConnectionProperty(String prop)
Parameters:
prop - a jConnect property name
Returns:
value assigned to the property requested.

setConnectionProperties

public void setConnectionProperties(Properties props)
                             throws SQLException
Provided as a replacement for being able to call Driver.getConnection(url, props).
Parameters:
props - the jConnect properties the user wants for the connection

setResourceManagerName

public void setResourceManagerName(String newRMName)
This logical name corresponds to the xa_open call from the XA Specification. If this object is a SybXADataSource representing an XA Server 11, then this is the string that corresponds to the lrm entry in the xa_config file.

If this object is an XADataSouce, then this string will be used for all XAConnections (and their corresponding XAResources) that are created from this data source. When this value is changed, subsequent XAConnections will use the new name.

Parameters:
newRMName - the non-null String name to give the resource manager.

getResourceManagerName

public String getResourceManagerName()
Returns:
current value of the resource manager name.

setResourceManagerType

public void setResourceManagerType(int type)
Inform this datasource that if XAConnections are to be created, that this type of resource manager should be expected.

This method is only necessary when the manager is an XA Server 11, and should then be called as setResourceManagerType(SybDataSource.RMTYPE_XA_11)

Parameters:
type - indicates what type of manager from the available values on this interface: RMTYPE_*

getResourceManagerType

public int getResourceManagerType()
Returns:
current type of resource manager