Chapter 2 Programming Information
This section describes the tasks you need to perform before you use jConnect.
There are several versions of jConnect; use a version setting to determine:
Only Adaptive Server Enterprise version 12.5 and later
support wide tables and unichar character data.
Table 2-1 lists the version settings available and their features.
Version constant | Features | Comments |
---|---|---|
VERSION_6 |
|
For jConnect version 5.x,
the default is VERSION_5.
For additional information, see the comments for VERSION_4. For more information on wide tables, see "Wide table support for Adaptive Server version 12.5". For more information on unichar and univarchar datatypes and Unicode, see "Using jConnect to pass Unicode data". |
VERSION_5 |
|
For jConnect version 5.x,
the default is VERSION_5.
For additional information, see the comments for VERSION_4. |
VERSION_4 |
|
For jConnect version 4.x
and earlier, the default is VERSION_2.Server messages are
localized according to the language setting in your local environment. The
languages supported are: Chinese, U.S. English, French, German,
Japanese, Korean, Portuguese, and Spanish.
The default behavior of Statement.cancel( ) is JDBC-compliant. Use CANCEL_ALL to set the behavior of Statement.cancel( ). See "CANCEL_ALL connection property". For information on Java objects as column data, see "Storing Java objects as column data in a table". |
VERSION_3 |
|
The default is VERSION_2.See the comments for VERSION_2. |
VERSION_2 |
|
The default version setting
for jConnect version 2.x is VERSION_2.
The LANGUAGE connection property determines the language in which messages from jConnect and the server appear. For information on the CHARSET and CHARSET_CONVERTER connection classes, see "jConnect character-set converters". The VERSION_2 default behavior of Statement.cancel( ) is not JDBC-compliant. Use CANCEL_ALL to set the behavior of Statement.cancel( ). See "CANCEL_ALL connection property". |
The version values are constant values from the SybDriver class. When referring to the version constant, use this syntax:
com.sybase.jdbcx.SybDriver.VERSION_5
Use SybDriver.setVersion( ) to set the jConnect version. The following code samples show how to load the jConnect driver and set the version.
For jConnect 4.x:
import com.sybase.jdbcx.SybDriver; SybDriver sybDriver = (SybDriver) Class.forName ("com.sybase.jdbc.SybDriver").newInstance();
sybDriver.setVersion (com.sybase.jdbcx.SybDriver.VERSION_4); DriverManager.registerDriver(sybDriver);
For jConnect 5.x:
import com.sybase.jdbcx.SybDriver; SybDriver sybDriver = (SybDriver) Class.forName ("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
sybDriver.setVersion (com.sybase.jdbcx.SybDriver.VERSION_5); DriverManager.registerDriver(sybDriver);
For wide table support with jConnect 4.x and 5.x:
To enable wide table support with Adaptive Server Enterprise version 12.5 and later, use SybDriver.setVersion( ) to set the jConnect version to 6:
sybDriver.setVersion (com.sybase.jdbcx.SybDriver.VERSION_6);
You can call setVersion( ) multiple times to change the version setting. New connections inherit the behavior associated with the version setting at the time the connection was made. Changing the version setting during a session does not affect the current connection.
As described in the next section, you can use JCONNECT_VERSION to override the SybDriver version setting and specify a different version setting for a specific connection.
Use JCONNECT_VERSION to specify the version setting for a specific session.You can set JCONNECT_VERSION to an integer value of "2," "3," "4," "5," or "6" depending on the characteristics you want (see Table 2-1).
CANCEL_ALL is a Boolean-valued connection property for specifying the behavior of the Statement.cancel( ) method.
In jConnect version 4.0 and earlier, the default for
CANCEL_ALL is true. In jConnect version 4.1 and later,
to comply with the JDBC specification, if you set the connection
property JCONNECT_VERSION to "4" or above,
the default setting for CANCEL_ALL is false.
The settings for CANCEL_ALL have the following effect on Statement.cancel( ):
The following example sets CANCEL_ALL to false. In the example, props is a Properties object for specifying connection properties.
... props.put("CANCEL_ALL", "false");
To cancel the execution of all Statement objects
on a connection, regardless of whether or not they have begun execution
on the server, use the extension method SybConnection.cancel(
).
To register and invoke the Sybase jConnect driver, use either of two suggested methods:
For jConnect 4.x:
Class.forName("com.sybase.jdbc.SybDriver").newInstance();
For jConnect 5.x:
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
Add the jConnect driver to the jdbc.drivers system property. At initialization, the DriverManager class attempts to load the drivers listed in jdbc.drivers. This is less efficient than the previous approach. You can list multiple drivers in this property, separated with a colon (:). The following code samples show how to add a driver to jdbc.drivers within a program:
For jConnect 4.x:
Properties sysProps = System.getProperties(); String drivers = "com.sybase.jdbc.SybDriver"; String oldDrivers = sysProps.getProperty("jdbc.drivers"); if (oldDrivers != null) drivers += ":" + oldDrivers; sysProps.put("jdbc.drivers", drivers.toString());
For jConnect 5.x:
Properties sysProps = System.getProperties(); String drivers = "com.sybase.jdbc2.jdbc.SybDriver"; String oldDrivers = sysProps.getProperty("jdbc.drivers"); if (oldDrivers != null) drivers += ":" + oldDrivers; sysProps.put("jdbc.drivers", drivers.toString());
System.getProperties( ) is not allowed
for Java applets. Use the
Class.forName( ) method,
instead.
Copyright © 2001 Sybase, Inc. All rights reserved. |
![]() |