Setting the jConnect version

The jConnect version property JCONNECT_VERSION determines the driver’s behavior and the features activated. For example, Adaptive Server 15.5 supports both jConnect 6.05 and 7.0, however, these two versions differ in their handling of datetime and time data. When connecting to Adaptive Server 15.5, jConnect 7.0, which supports microsecond granularity for time data, uses bigdatetime or bigtime even if the target Adaptive Server columns are defined as datetime or time. jConnect 6.05, however, does not support microsecond granularity and always transfers datetime or time data when connecting to Adaptive Server 15.5.

You can set the jConnect version by using either the SybDriver.setVersion method or the JCONNECT_VERSION connection property.

Using SybDriver. setVersion

The setVersion method affects the jConnect default behavior for all connections created by the SybDriver object. 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 is made. Changing the version setting during a session does not affect current connections. You can use the com.sybase.jdbcx.SybDriver.VERSION_LATEST constant to ensure that you are always requesting the highest version value possible for the jConnect driver you are using. However, by setting the version to com.sybase.jdbcx.SybDriver.VERSION_LATEST, you may see behavior changes if you replace your current jConnect driver with a newer one.

This code sample shows how to load the jConnect driver and set its version:

import java.sql.DriverManager;
import com.sybase.jdbcx.SybDriver;
SybDriver sybDriver = (SybDriver)
   Class.forName("com.sybase.jdbc4.jdbc.SybDriver")
   .newInstance();
sybDriver.setVersion(com.sybase.jdbcx.SybDriver.
   VERSION_7);
DriverManager.registerDriver(sybDriver);

Using JCONNECT_ VERSION

You can use the JCONNECT_VERSION connection property to override the SybDriver version setting and specify a different version setting for a specific connection. Table 2-1 lists the valid JCONNECT_VERSION values and the jConnect characteristics associated with these values.

Table 2-1: jConnect version settings and their features

JCONNECT_VERSION

Features

“7.0”

jConnect 7.0 behaves in the same way as jConnect 6.05, except that in this version:

“6.05”

jConnect 6.05 behaves in the same way as jConnect 6.0, except that in this version:

“6”

jConnect 6.0 behaves in the same way as jConnect 5.x, except that in this version:

“5”

jConnect 5.x behaves in the same way as jConnect 4.0.

“4”

jConnect 4.0 behaves in the same way as jConnect 3.0, except that in this version:

  • The default value of the LANGUAGE connection property is null.

  • The default behavior of Statement.cancel is to cancel only the Statement object on which it is invoked. This behavior is JDBC-compliant.

    Use CANCEL_ALL to set the behavior of Statement.cancel.

  • You can use JDBC 2.0 methods to store and retrieve Java objects as column data. See “Storing Java objects as column data in a table”.

“3”

jConnect 3.0 behaves in the same way as jConnect 2.0, except that in this version:

  • If the CHARSET connection property does not specify a character set, jConnect uses the default character set of the database.

  • The default value for CHARSET_CONVERTER is the CheckPureConverter class.

“2”

  • The default value of the LANGUAGE connection property is us_english.

  • If the CHARSET connection property does not specify a character set, the default character set is iso_1.

  • The default value for CHARSET_CONVERTER is the TruncationConverter class, unless the CHARSET connection property specifies a multibyte or 8-bit character set, in which case the default CHARSET_CONVERTER is the CheckPureConverter class. See “jConnect character-set converters”.

  • The default behavior of Statement.cancel is to cancel the object it is invoked on and any other Statement objects that have begun to execute and are waiting for results. This behavior is not JDBC-compliant.

    Use CANCEL_ALL to set the behavior of Statement.cancel.