
Programming Information
Setting up jConnect
This section describes the tasks you need to perform before
you use jConnect.
Setting the jConnect version
There are several versions of jConnect. Use a version setting
to determine:
- The default
value of the LANGUAGE
connection property
- The version-specific features that are available
- The default character set, if no character set is
specified through the CHARSET
connection property
- The default value of the CHARSET_CONVERTER
connection property
- The default value of the CANCEL_ALL
connection property, which is used to set the behavior of Statement.cancel, which
by default cancels the object on which it is invoked and any other Statement objects
that have begun to execute and are waiting for results
- If you are requesting support for wide tables from
the server
- If you would like
to request server support for storing character data in unichar (Unicode)
columns
Only Adaptive Server version 12.5 and later support
wide tables and unichar character data.
- If you would like to request support from the server
for the date and time SQL
datatypes
Only Adaptive Server version 12.5.1 and later support
the date and time SQL
datatypes.
Table 2-1 lists
the version settings available and their features.
Table 2-1: jConnect version settings and their features
| JCONNECT_VERSION
|
Features
|
Comments
|
| "6.05"
|
- jConnect
requests support for the date and time SQL
datatypes from the server. This request is ignored by servers other
than Adaptive Server version 12.5.1 and later.
- jConnect requests support for the unichar and univarchar datatypes
from the server. This request is ignored by servers other than Adaptive
Server 12.5 and later.
- The default value of the LANGUAGE connection property
is null.
- By default, Statement.cancel cancels
only the Statement object it is invoked on.
- Computed columns - the jConnect driver supports
accessing these specific computed columns, including their metadata information.
- Large identifiers - the jConnect driver
fully supports large identifiers in your applications. Large identifiers
limits, which define the length of object names or identifiers,
is increased to 255 bytes. The new large identifier applies to most
user-defined identifiers, including table name, column name, and
index name. As a result of the expanded limits.
|
For jConnect version 6.05,
the default is "6.05"
For additional information for date and time datatypes,
see "Using date and time datatypes".
For more information on unichar and univarchar datatypes
and Unicode, see "Using jConnect to pass Unicode data".
For more information on wide tables, see "Using wide table support for ASE 12.5 and later".
|
| "6"
|
- jConnect
requests support for the date and time SQL
datatypes from the server. This request is ignored by servers other
than Adaptive Server version 12.5.1 and later.
- jConnect requests support for the unichar and univarchar datatypes
from the server. This request is ignored by servers other than Adaptive
Server 12.5 and later.
- jConnect requests support for wide tables from the
server. This request is ignored by servers other than Adaptive Server
12.5 and later.
- The default value of the LANGUAGE connection property
is null.
- 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.
The
default value of DISABLE_UNICHAR_SENDING is set
to false.
- By default, Statement.cancel cancels
only the Statement object it is invoked on.
- JDBC 2.0 methods can be used to store and retrieve
Java objects as column data.
|
For jConnect version 6.0, the
default is VERSION_6.
For additional information for date and time datatypes,
see "Using date and time datatypes".
For more information on unichar and univarchar datatypes
and Unicode, see "Using jConnect to pass Unicode data".
For more information on wide tables, see "Using wide table support for ASE 12.5 and later".
|
| "5"
|
- The default value of the LANGUAGE connection property
is null.
- 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.
- By default, Statement.cancel cancels
only the Statement object it is invoked on.
- JDBC 2.0 methods can be used to store and retrieve
Java objects as column data.
|
For jConnect versions
5.x, the default is VERSION_5.
|
| "4"
|
- The default value of the LANGUAGE connection property
is null.
- 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.
- By default, Statement.cancel cancels
only the Statement object it is invoked on.
- JDBC 2.0 methods can be used to store and retrieve
Java objects as column data.
|
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, Polish, 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".
|
| "3"
|
- The default value of the LANGUAGE connection property
is us_english.
- 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.
- By default, Statement.cancel cancels
the object it is invoked on and any other Statement objects
that have begun to execute and are waiting for results.
|
See the comments for VERSION_2.
|
| "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.
- By default, Statement.cancel cancels
the object it is invoked on and any other Statement objects
that have begun to execute and are waiting for results.
|
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".
|
JCONNECT_VERSION connection property
As described in this 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
a value of "2," "3," "4," "5," "6," or "6.05," depending
on the characteristics you want.
When referring to the version constant, use this syntax:
com.sybase.jdbcx.SybDriver.VERSION_6
Although the preferred approach is to use JCONNECT_VERSION
connection property, you can alternately use constant values in
SybDriver.
Use SybDriver.setVersion to set the jConnect
version. The setVersion method affects the jConnect
default behavior for all connections created by the SybDriver object.
However, you can use the JCONNECT_VERSION connection property
to set version-specific behavior for individual connections. The
following code sample shows how to load the jConnect driver and
set the version:
import com.sybase.jdbcx.SybDriver;
SybDriver sybDriver = (SybDriver)
Class.forName ("com.sybase.jdbc3.jdbc.SybDriver").newInstance();
sybDriver.setVersion
(com.sybase.jdbcx.SybDriver.VERSION_6);
DriverManager.registerDriver(sybDriver);
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. jConnect provides a com.sybase.jdbcx.SybDriver.VERSION_LATEST constant
which can be used 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.
CANCEL_ALL connection property
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 later,
the default setting for CANCEL_ALL is "false."
The settings for CANCEL_ALL have the following effect
on Statement.cancel( ):
- If CANCEL_ALL is "false,"
invoking Statement.cancel cancels
only the Statement object it is invoked on. Thus,
if stmtA is a Statement object, stmtA.cancel cancels
the execution of the SQL statement contained in stmtA in
the database, but no other statements are affected. stmtA is canceled
whether it is in cache waiting to execute or has started to execute and
is waiting for results.
- If CANCEL_ALL is "true," invoking Statement.cancel cancels
not only the object it is invoked on, but also any other Statement objects
on the same connection that have executed and are waiting for results.
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.
Invoking the jConnect driver
To register and invoke the Sybase jConnect driver, use either
of the following two suggested methods:
- Use Class.forName as shown:
Class.forName("com.sybase.jdbc3.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 Class.forName call 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:
Properties sysProps = System.getProperties();
String drivers = "com.sybase.jdbc3.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. Instead, use the Class.forName method.
|
Copyright (C) 2005. Sybase Inc. All rights reserved.
|
|