Programming Information


Establishing a connection

This section describes how to establish a connection to an Adaptive Server or Adaptive Server Anywhere database using jConnect.

Setting connection properties

Table 2-2 lists the connection properties for jConnect and indicates their default values. You must set the connection properties before you make a connection.

There are two ways to set the driver connection properties:

Note   Driver connection properties set in the URL do not override any corresponding connection properties set in the application using the DriverManager.getConnection method.

To obtain a current list of properties for any driver, use the Driver.getDriverPropertyInfo(String url, Properties props), which returns an array of DriverPropertyInfo objects. The array lists:

Driver connection property names are not case sensitive (jConnect uses the String.equalsIgnoreCase(String) method to compare property names).

Table 2-2: Connection properties
Property Description Default value
APPLICATIONNAME Specifies an application name. This is a user-defined property. The server side can be programmed to interpret the value given to this property. Null
BE_AS_JDBC_COMPLIANT_
AS_POSSIBLE
Adjusts other properties to ensure that jConnect methods respond in a way that is as compliant as possible with the JDBC 3.0 standard.

These properties are affected (and overridden) when this property is set to "true":

  • CANCEL_ALL (set to "false")
  • LANGUAGE CURSOR (set to "false")
  • SELECT_OPENS_CURSOR (set to "true")
  • FAKE_METADATA (set to "true")
  • GET_BY_NAME_USES_COLUMN_LABEL (set to "false")
False
CACHE_COLUMN_METADATA To improve performance when you are setting DYNAMIC_PREPARE to "true," jConnect will cache ResultSet Metadata on consecutive executions. None
CANCEL_ALL Determines the behavior of the Statement.cancel method. See "CANCEL_ALL connection property". Depends on version setting. See "Setting the jConnect version".
CAPABILITY_TIME Used only when JCONNECT_VERSION >= 6. When jConnect is connected to a server that supports the TIME datatype, and all parameters of type java.sql.Time or escape literals {t ...} are processed as TIME. Previous versions of jConnect treat such parameters as DATETIME and prepend '1970-01-01' to the java.sql.Time parameter. If the underlying datatype is datetime or smalldatetime the date part also gets stored in the database. In the new versions of jConnect when TIME is processed, then the server converts time to the underlying datatype and will prepend its own base year. This can result in incompatibilities between old and new data. If you are using datetime or smalldatetime datatypes for java.sql.Time, then for backward compatiblity you should leave CAPABILITY_TIME as false. Leaving this property as false forces jConnect to process java.sql.Time parameters or escape literals {t ...} as DATETIME regardless of the server capability of handling TIME datatype.Setting this property to true will cause jConnect to process java.sql.Time parameters as TIME datatype when connected to ASE 12.5.1 or later. Sybase recommends you leave this property as false if you are using smalldatetime or datetime columns to store time values. False
CAPABILITY_WIDETABLE If you do not require JDBC ResultSetMetaData like Column name as a performance improvement, you can set this to "false." The result is that less data is exchanged over the network and increases performance. Unless you are using EAServer, Sybase recommends, that you use the default setting. See "Using wide table support for ASE 12.5 and later". False
CHARSET Specifies the character set for strings passed to the database. If the CHARSET value is null, jConnect uses the default character set of the server to send string data to the server. If you specify a CHARSET, the database must be able to handle characters in that format. If the database cannot do so, a message is generated indicating that character conversion cannot be properly completed.

Note   When using jConnect 6.05 with DISABLE_UNICHAR_SENDING set to "false", jConnect detects when a client is trying to send characters to the server that cannot be represented in the character set that is being used for the connection. When that occurs, jConnect sends the character data to the server as unichar data, which allows clients to insert Unicode data into unichar/univarchar columns and parameters.
Null
CHARSET_CONVERTER_CLASS Specifies the character-set converter class you want jConnect to use. jConnect uses the version setting from SybDriver.setVersion, or the version passed in with the JCONNECT_VERSION property, to determine the default character-set converter class to use. See "Selecting a character-set converter" for details. Version-dependent
CLASS_LOADER A property you set to a DynamicClassLoader object that you create. The DynamicClassLoader is used to load Java classes that are stored in the database but which are not in the CLASSPATH at application start-up time. See"Using dynamic class loading" for more information. Null
CONNECTION_FAILOVER Used with the Java Naming and Directory Interface (JNDI). See "CONNECTION_FAILOVER connection property". True
DISABLE_UNICHAR_SENDING When a client application sends unichar characters to the server (along with non-unichar characters), there is a slight performance hit for any character data sent to the database. This property defaults to "false" in jConnect 6.05. Clients using older versions of jConnect who wish to send unichar data to the database must set this property to "false". See "Using jConnect to pass Unicode data". Version-dependent
DISABLE_UNPROCESSED_
PARAM_WARNINGS
Disables warnings. During results processing for a stored procedure, jConnect often reads return values other than row data. If you do not process the return value, jConnect raises a warning. To disable these warnings (which can help performance), set this property to "true." False
DYNAMIC_PREPARE Determines whether dynamic SQL prepared statements are precompiled in the database. See "DYNAMIC_PREPARE connection property". False
ENABLE_SERVER_PACKETSIZE Allows you to specify if you want to use server specified packet size. By default this property is set to "true" that uses the server specified packet size. True
ENCRYPT_PASSWORD Allows a secure login. When it is set to "true," both login and remote site passwords are encrypted and sent to the server. False
ESCAPE_PROCESSING_DEFAULT Circumvents processing of JDBC function escapes in SQL statements. By default, jConnect parses all SQL statements submitted to the database for valid JDBC function escapes. If your application is not going to use JDBC function escapes in its SQL calls, you can set this connection property to "false" to avoid this processing. This can provide a slight performance benefit. True
EXPIRESTRING Contains the license expiration date. Expiration is never except for evaluation copies of jConnect. This is a read-only property. Never
FAKE_METADATA Returns phony metadata. When you call the ResultSetMetaData methods getCatalogName, getSchemaName, and getTableName and this property is set to "true," the call returns empty strings ("") because the server does not supply useful metadata.

When this property is set to "false," calling these methods throws a "Not Implemented" SQLException.

Note   If you have enabled wide tables and are using an Adaptive Server 12.5 or later, this property setting is ignored, because the server does supply useful metadata.
False
GET_BY_NAME_USES_
COLUMN_LABEL
Provides backward compatibility with versions of jConnect earlier than 6.0.

With Adaptive Server version 12.5, jConnect has access to more metadata than was previously available. Previous to version 12.5, column name and column alias meant the same thing. jConnect can now differentiate between the two when used with a 12.5 or later Adaptive Server with wide tables enabled.

To preserve backward compatibility, set this property to "true."If you want calls to getByte, getInt, get* (String columnName) to look at the actual name for the column (called for in the JDBC 2.0 specification), set this property to "false."
True
GSSMANAGER_CLASS Specifies a third-party implementation of the org.ietf.jgss.GSSManager class.

This property can be set to a string or a GSSManager object.

If the property is set to a string, the value should be the fully qualified class name of the third-party GSSManager implementation. If the property is set to an object, the object must extend the org.ietf.jgss.GSSManager class. See Chapter 3, "Security" for more information.
Null
HOSTNAME Identifies the name of the current host. None.
The max length is 30 characters and, if exceeded, it is truncated to 30.
HOSTPROC Identifies the application process on the host machine. None
IGNORE_DONE_IN_PROC Determines that intermediate update results (as in stored procedures) are not returned, only the final result set. False
IS_CLOSED_TEST Allows you to specify what query, if any, is sent to the database when Connection.isClosed is called. For additional information, see the "Using Connection.isClosed and IS_CLOSED_TEST". Null
JCONNECT_VERSION Sets version-specific characteristics. See "JCONNECT_VERSION connection property". 6
LANGUAGE Sets the language for error messages returned from the server and for jConnect messages. The setting must match a language in syslanguages. Version dependent. See "Setting the jConnect version".
LANGUAGE_CURSOR Determines that jConnect uses "language cursors" instead of "protocol cursors."
See "Cursor performance".
False
LITERAL_PARAMS When set to "true," any parameters set by the setXXX methods in the PreparedStatement interface are inserted literally into the SQL statement when it is executed.

If set to "false," parameter markers are left in the SQL statement and the parameter values are sent to the server separately.
False
USE_METADATA Creates and initializes a DatabaseMetaData object when you establish a connection. The DatabaseMetaData object is necessary to connect to a specified database.

jConnect uses DatabaseMetaData for some features, including Distributed Transaction Management support (JTA/JTS) and dynamic class loading (DCL).

If you receive error 010SJ, which indicates that your application requires metadata, install the stored procedures for returning metadata that come with jConnect. See "Installing Stored Procedures" in Chapter 3 of the jConnect for JDBC Installation Guide.
True
PACKETSIZE Identifies the network packet size. If you are using ASE 15.0, Sybase recommends that you do not set this property and allow jConnect and ASE 15.0 to pick the network packet size that is appropriate for your environment. See 512
PASSWORD Identifies the login password.

Set automatically if using the getConnection(String, String, String) method, or explicitly if using getConnection(String, Props).
None
PRELOAD_JARS Contains a comma-separated list of .jar file names that are associated with the CLASS_LOADER that you specify. These .jar files are loaded at connect time, and are available for use by any other connection using the same jConnect driver. See "Preloading .jar files" for more information. Null
PROTOCOL_CAPTURE Specifies a file for capturing TDS communication between an application and an Adaptive Server. Null
PROXY Specifies a gateway address. For the HTTP protocol, the URL is http://host:port.

To use the HTTPS protocol that supports encryption, the URL is https://host:port/servlet_alias.
None
QUERY_TIMEOUT_CANCELS_ALL Forces jConnect to cancel all Statements on a Connection when a read timeout is encountered. This behavior can be used when a client has calls execute() and the timeout occurs because of a deadlock (for example, trying to read from a table that is currently being updated in another transaction). The default value is false. Depending on future discussions with Sun, this property may be lumped in with the property values affected by the BE_AS_JDBC_COMPLIANT_AS_POSSIBLE property. False
REMOTEPWD Contains remote server passwords for access through server-to-server remote procedure calls. See "Performing server-to-server remote procedure calls". None
REPEAT_READ Determines whether the driver keeps copies of columns and output parameters so that columns can be read out of order or repeatedly. See "REPEAT_READ connection property". True
REQUEST_HA_SESSION Indicates whether the connecting client wants to begin an high availability (HA) failover session with a version 12 or later Adaptive Server configured for failover. See "Implementing high availability failover support".

Note   Setting this property to "true" causes jConnect to attempt a failover login. If you do not set this connection property, a failover session does not start, even if the server is configured for failover.


You cannot reset the property once a connection has been made.If you want more flexibility for requesting failover sessions, code the client application to set REQUEST_HA_SESSION at runtime.
False
REQUEST_KERBEROS_SESSION Determines whether jConnect uses Kerberos for authentication. If this property is set to "true," a value for the SERVICE_PRINCIPAL_NAME property must also be specified.

You may also wish to provide a value for the GSSMANAGER_CLASS property. See Chapter 3, "Security" for more information.
False
RMNAME Sets the Resource Manager name when using distributed transactions (XA). This property overrides a Resource Manager name that may be set in an LDAP server entry. See "Distributed transaction management support" for more information. Null
SECONDARY_SERVER_
HOSTPORT
Sets the hostname and port for the secondary server when the client is using an HA failover session. The value for this property should be in the form of hostName:portNumber. This property is ignored unless you have also set REQUEST_HA_SESSION to "true." See "Implementing high availability failover support" for more information. Null
SELECT_OPENS_CURSOR Determines whether calls to Statement.executeQuery automatically generate a cursor when the query contains a FOR UPDATE clause.

If you have previously called Statement.setFetchSize or
Statement.setCursorName on the same statement, a setting of "true" for SELECT_OPENS_CURSOR has no effect.

Note   You may experience some performance degradation when SELECT_OPENS_CURSOR is set to "true."


See "Using cursors with result sets" for more information on using cursors with jConnect.
False
SERIALIZE_REQUESTS Determines whether jConnect waits for responses from the server before sending additional requests. False
SERVER_INITIATED_
TRANSACTIONS
Allows the server to control transactions. By default the property is set to "true" and jConnect lets the server start and control transactions by using Transact-SQL[TM] set chained on."If set to "false," the transactions are started and controlled by jConnect by using transact sql "begin tran." Sybase recommends that you allow the server to control the transactions. True
SERVICENAME Indicates the name of a back-end database server that a DirectConnect gateway serves. Also used to indicate which database should be used upon connecting to Adaptive Server Anywhere. None
SERVERTYPE When connected to OpenSwitch set this property to "OSW." This allows jConnect to send certain instructions to OpenSwitch that allows OpenSwitch to remember initial connection settings for example, isolation level, textsize, quoted identifier and autocommit when OpenSwitch is moved to a different server instance. None
SERVICE_PRINCIPAL_NAME Used when establishing a Kerberos connection to Adaptive Server Enterprise. The value of this property should correspond both to the server entry in your Key Distribution Center (KDC) and to the server name under which your database is running.

The value of the SERVICE_PRINCIPAL_NAME property is ignored if the REQUEST_KERBEROS_SESSION property is set to "false." See Chapter 3, "Security" for more information.
Null
SESSION_ID A TDS session ID. When this property is set, jConnect assumes that an application is trying to resume communication on an existing TDS session held open by the TDS-tunnelling gateway. jConnect skips the login negotiations and forwards all requests from the application to the specified session ID. Null
SESSION_TIMEOUT Specifies the amount of time (in seconds) that an HTTP-tunnelled session (created using the jConnect TDS-tunnelling servlet) remains alive while idle. After the specified time, the connection is automatically closed. For more information about the TDS-tunnelling servlet, see page §. Null
SQLINITSTRING Defines a set of commands to be passed to the database server when a connection is opened. These must be SQL commands that can be executed using the Statement.executeUpdate method. Null
STREAM_CACHE_SIZE Specifies the maximum size used to cache statement response streams. Null (unlimited cache size)
SYBSOCKET_FACTORY Enables jConnect to use your custom socket implementation.

Set SYBSOCKET_FACTORY either to:
  • The name of a class that implements com.sybase.jdbcx.SybSocketFactory; or
  • "DEFAULT," which instantiates a new
    java.net.Socket( )


Use this property to make an SSL connection to your database.

See "Implementing custom socket plug-ins".
Null
TEXTSIZE Allows you to set the TEXTSIZE. By default ASE and ASA allow 32627 bytes to be read from an image or text column. If you have the jConnect mda tables installed, jConnect changes that value to 2GB. However setting this value when connected to OpenSwitch allows the connection to remember the setting when OpenSwitch is moved to a different server instance. 2GB
USER Specifies the login ID.

Set automatically if using the getConnection(String, String, String) method, or explicitly if using getConnection(String, Props).
None
VERSIONSTRING Provides read-only version information for the JDBC driver. jConnect driver version

The following code is an example of setting connection properties. The sample programs provided with jConnect also contain examples of setting these properties.

 Properties props = new Properties();
   props.put("user", "userid");
   props.put("password",  "user_password");
 /*
  * If  the program is an applet that wants to access
  * a  server that is not on the same host as the
  * web  server, then it uses a proxy gateway.
  */
   props.put("proxy", "localhost:port");
 /*
  * Make  sure you set connection properties before
  * attempting  to make a connection. You can also
  * set the  properties in the URL.
  */
 Connection  con = DriverManager.getConnection
   ("jdbc:sybase:Tds:host:port",  props);

Connecting to Adaptive Server

In your Java application, define a URL using the jConnect driver to connect to an Adaptive Server. The basic format of the URL is:

jdbc:sybase:Tds:host:port

where:

You can connect to a specific database using this format:

jdbc:sybase:Tds:host:port/database 

Note   To connect to a specific database using Adaptive Server Anywhere or DirectConnect, use the SERVICENAME connection property to specify the database name instead of "/database."

Example

The following code creates a connection to an Adaptive Server on host "myserver" listening on port 3697:

SysProps.put("user","userid");
SysProps.put("password","user_password");
String  url = "jdbc:sybase:Tds:myserver:3697";
Connection_con =
    DriverManager.getConnection(url,SysProps);

URL connection property parameters

You can specify the values for the jConnect driver connection properties when you define a URL.

Note   Driver connection properties set in the URL do not override any corresponding connection properties set in the application using the DriverManager.getConnection method.

To set a connection property in the URL, append the property name and its value to the URL definition. Use this syntax:

jdbc:sybase:Tds:host:port/database?
   property_name=value

To set multiple connection properties, append each additional connection property and value, preceded by "&." For example:

jdbc:sybase:Tds:myserver:1234/mydatabase?
   LITERAL_PARAMS=true&PACKETSIZE=512&HOSTNAME=myhost

If the value for one of the connection properties contains "&," precede the "&" in the connection property value with a backslash (\). For example, if your host name is "a&bhost," use this syntax:

jdbc:sybase:Tds:myserver:1234/mydatabase?
   LITERAL_PARAMS=true&PACKETSIZE=512&HOSTNAME=
   a\&bhost

Do not use quotes for connection property values, even if they are strings. For example, use:

HOSTNAME=myhost

not:

HOSTNAME="myhost"

Connecting to a server using JNDI

In jConnect, you can use the Java Naming and Directory Interface (JNDI) to provide connection information, which offers:

To use jConnect with JNDI, you need to make sure that certain information is available in any directory service that JNDI accesses and that required information is set in the javax.naming.Context class. This section covers the following topics:

Connection URL for using JNDI

To specify that jConnect should use JNDI to obtain connection information, place "jndi" as the URL protocol after "sybase":

jdbc:sybase:jndi:protocol-information-for-use-with-JNDI

Anything that follows "jndi" in the URL is handled through JNDI. For example, to use JNDI with the Lightweight Directory Access Protocol (LDAP), you might enter:

jdbc:sybase:jndi:ldap://LDAP_hostname:port_number/servername=
  Sybase11,o=MyCompany,c=US

This URL tells JNDI to obtain information from an LDAP server, gives the host name and port number of the LDAP server to use, and provides the name of a database server in an LDAP-specific form.

Required directory service information

When you use JNDI with jConnect, JNDI needs to return the following information for the target database server:

This information needs to be stored according to a fixed format in any directory service used for providing connection information. The required format consists of a numerical object identifier (OID), which identifies the type of information being provided (for example, the destination database), followed by the formatted information (see "Example 1" on page 23).

Note   You can use the alias name to reference the attribute instead of the OID. See "Example 2" on page 24.

Table 2-3 shows the required formatting.

Table 2-3: Directory service information for JNDI
Attribute description Alias OID (object_id)
Interfaces entry replacement in LDAP directory services sybaseServer 1.3.6.1.4.1.897.4.1.1
Collection point for sybaseServer LDAP attributes sybaseServer 1.3.6.1.4.1.897.4.2
Version Attribute sybaseVersion 1.3.6.1.4.1.897.4.2.1
Servername Attribute sybaseServer 1.3.6.1.4.1.897.4.2.2
Service Attribute sybaseService 1.3.6.1.4.1.897.4.2.3
Status Attribute sybaseStatus 1.3.6.1.4.1.897.4.2.4
Address Attribute sybaseAddress 1.3.6.1.4.1.897.4.2.5
Security Mechanism Attribute sybaseSecurity 1.3.6.1.4.1.897.4.2.6
Retry Count Attribute sybaseRetryCount 1.3.6.1.4.1.897.4.2.7
Loop Delay Attribute sybaseRetryDelay 1.3.6.1.4.1.897.4.2.8
jConnect Connection Protocol sybaseJconnectProtocol 1.3.6.1.4.1.897.4.2.9
jConnect Connection Property sybaseJconnectProperty 1.3.6.1.4.1.897.4.2.10
Database Name sybaseDatabasename 1.3.6.1.4.1.897.4.2.11
High Availability Failover Servername Attribute sybaseHAservername 1.3.6.1.4.1.897.4.2.15
ResourceManager Name sybaseResourceManagerName 1.3.6.1.4.1.897.4.2.16
ResourceManager Type sybaseResourceManagerType 1.3.6.1.4.1.897.4.2.17
JDBCDataSource Interface sybaseJdbcDataSource-
Interface
1.3.6.1.4.1.897.4.2.18
ServerType sybaseServerType 1.3.6.1.4.1.897.4.2.19

Note   Attributes in italics are required.

The following examples show connection information entered for the database server "SYBASE11" under an LDAP directory service. Example 1 uses the attribute OID. Example 2 uses the attribute alias, which is not case sensitive. You can use either the OID or the alias.

Example 1

dn: servername=SYBASE11,o=MyCompany,c=US
 servername:SYBASE11
 1.3.6.1.4.1.897.4.2.5:TCP#1#giotto  1266
 1.3.6.1.4.1.897.4.2.5:TCP#1#giotto  1337
 1.3.6.1.4.1.897.4.2.5:TCP#1#standby1  4444
 1.3.6.1.4.1.897.4.2.10:REPEAT_READ=false&PACKETSIZE=1024
 1.3.6.1.4.1.897.4.2.10:CONNECTION_FAILOVER=true
 1.3.6.1.4.1.897.4.2.11:pubs2
 1.3.6.1.4.1.897.4.2.9:Tds

Example 2

dn: servername=SYBASE11,o=MyCompany,c=US
 servername:SYBASE11
 sybaseAddress:TCP#1#giotto  1266
 sybaseAddress:TCP#1#giotto  1337
 sybaseAddress:TCP#1#standby1  4444
 sybaseJconnectProperty:REPEAT_READ=false&PACKETSIZE=1024
 sybaseJconnectProperty:CONNECTION_FAILOVER=true
 sybaseDatabasename:pubs2
 sybaseJconnectProtocol:Tds

In these examples, SYBASE11 can be accessed through either port 1266 or port 1337 on host "giotto," and it can be accessed through port 4444 on host "standby1." Two connection properties, REPEAT_READ and PACKETSIZE, are set within one entry. The CONNECTION_FAILOVER connection property is set as a separate entry. Applications connecting to SYBASE11 are initially connected with the pubs2 database. You do not need to specify a connection protocol, but if you do, you must enter the attribute as "Tds ", not "TDS ".

CONNECTION_FAILOVER connection property

CONNECTION_FAILOVER is a Boolean-valued connection property you can use when jConnect uses JNDI to get connection information.

If CONNECTION_FAILOVER is set to "true," jConnect makes multiple attempts to connect to a server. If one attempt to connect to a host and port number associated with a server fails, jConnect uses JNDI to get the next host and port number associated with the server and attempts to connect through them. Connection attempts proceed sequentially through all the hosts and ports associated with a server.

For example, if CONNECTION_FAILOVER is set to "true," and a database server is associated with the following hosts and port numbers, as in the earlier LDAP example:

1.3.6.1.4.1.897.4.2.5:TCP#1#giotto  1266
1.3.6.1.4.1.897.4.2.5:TCP#1#giotto  1337
1.3.6.1.4.1.897.4.2.5:TCP#1#standby  4444

To get a connection to the server, jConnect tries to connect to the host "giotto" at port 1266. If this fails, jConnect tries port 1337 on "giotto." If this fails, jConnect tries to connect to host "standby1" through port 4444.

The default for CONNECTION_FAILOVER is "true."

If CONNECTION_FAILOVER is set to "false," jConnect attempts to connect to an initial host and port number. If the attempt fails, jConnect throws a SQL exception and does not try again.

Providing JNDI context information

To use jConnect with JNDI, you should be familiar with the JNDI specification from Sun Microsystems, available from the Web:

http://java.sun.com/products/jndi

In particular, you need to make sure that required initialization properties are set in javax.naming.directory.DirContext when JNDI and jConnect are used together. These properties can be set either at the system level or at runtime.

Two key properties are:

The following example shows how to set context properties at runtime and how to get a connection using JNDI and LDAP. In the example, the INITIAL_CONTEXT_FACTORY context property is set to invoke the Sun Microsystem implementation of an LDAP service provider. The PROVIDER_URL context property is set to the URL of an LDAP directory service located on the host "ldap_server1" at port 983.

Properties props = new  Properties();
 
 /* We want  to use LDAP, so INITIAL_CONTEXT_FACTORY is set  to the
 * class name of an LDAP context factory.  In this case, the 
 * context factory is provided  by Sun's implementation of a 
 * driver  for LDAP directory service.
 */
 props.put(Context.INITIAL_CONTEXT_FACTORY,
   "com.sun.jndi.ldap.LdapCtxFactory");
 
 /* Now,  we set PROVIDER_URL to the URL of the LDAP server that 
 * is  to provide directory information for the connection.
 */
 props.put(Context.PROVIDER_URL,  "ldap://ldap_server1:983");
 
 /* Set  up additional context properties, as needed. */
 props.put("user",  "xyz");
 props.put("password", "123");
 
 /* get  the connection */
 Connection con = DriverManager.getConnection
   ("jdbc:sybase:jndi:ldap://ldap_server1:983" +
   "/servername=Sybase11,o=MyCompany,c=US",props); 

The connection string passed to getConnection contains LDAP-specific information, which the developer must provide.

When JNDI properties are set at runtime, as in the preceding example, jConnect passes them to JNDI to be used in initializing a server, as in the following jConnect code:

javax.naming.directory.DirContext  ctx =
   new javax.naming.directory.InitialDirContext(props);

jConnect then obtains the connection information it needs from JNDI by invoking DirContext.getAtributes, as in the following example, where ctx is a DirContext object:

javax.naming.directory.Attributes attrs =
   ctx.getAttributes(ldap://ldap_server1:983/servername=
     Sybase11,  SYBASE_SERVER_ATTRIBUTES);

In the example, SYBASE_SERVER_ATTRIBUTES is an array of strings defined within jConnect. The array values are the OIDs for the required directory information listed in Table 2-3.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.