Sybase Jconnect For JDBC PDF
Sybase Jconnect For JDBC PDF
Sybase Jconnect For JDBC PDF
Programmer’s Reference
This publication pertains to jConnect for JDBC version 4.0 of the Sybase database
management software and to any subsequent version until otherwise indicated in
new editions or technical notes. Information in this document is subject to change
without notice. The software described herein is furnished under a license
agreement, and it may be used or copied only in accordance with the terms of that
agreement.
Document Orders
To order additional documents, U.S. and Canadian customers should call
Customer Fulfillment at (800) 685-8225, fax (617) 229-9845.
Customers in other countries with a U.S. license agreement may contact Customer
Fulfillment via the above fax number. All other international customers should
contact their Sybase subsidiary or local distributor.
Upgrades are provided only at regularly scheduled software release dates.
Copyright © 1989–1998 by Sybase, Inc. All rights reserved.
No part of this publication may be reproduced, transmitted, or translated in any
form or by any means, electronic, mechanical, manual, optical, or otherwise,
without the prior written permission of Sybase, Inc.
Sybase Trademarks
Sybase, the Sybase logo, APT-FORMS, Certified SYBASE Professional, Column
Design, Data Workbench, First Impression, InfoMaker, ObjectCycle, PowerBuilder,
PowerDesigner, Powersoft, Replication Server, S-Designor, SQL Advantage, SQL
Debug, SQL SMART, Transact-SQL, Visual Components, VisualWriter, and VQL
are registered trademarks of Sybase, Inc. Adaptable Windowing Environment,
Adaptive Component Architecture, Adaptive Server, Adaptive Server Anywhere,
Adaptive Server Enterprise Monitor, Adaptive Server IQ, Adaptive Warehouse,
ADA Workbench, AnswerBase, Application Manager, AppModeler, APT-Build,
APT-Edit, APT-Execute, APT-Library, APT-Translator, APT Workbench, Backup
Server, BayCam, Bit-Wise, ClearConnect, Client-Library, Client Services,
CodeBank, Connection Manager, DataArchitect, Database Analyzer, DataExpress,
Data Pipeline, DataWindow, DB-Library, dbQueue, Developers Workbench,
DirectConnect, Distribution Agent, Distribution Director, Embedded SQL, EMS,
Enterprise Client/Server, Enterprise Connect, Enterprise Manager, Enterprise SQL
Server Manager, Enterprise Work Architecture, Enterprise Work Designer,
Enterprise Work Modeler, EWA, Formula One, Gateway Manager, GeoPoint,
ImpactNow, InformationConnect, InstaHelp, InternetBuilder, iScript, Jaguar CTS,
jConnect for JDBC, KnowledgeBase, Logical Memory Manager,
MainframeConnect, Maintenance Express, MAP, MDI Access Server, MDI
Database Gateway, media.splash, MetaBridge, MetaWorks, MethodSet, Net-
Gateway, NetImpact, Net-Library, Next Generation Learning, ObjectConnect,
OmniConnect, OmniSQL Access Module, OmniSQL Toolkit, Open Client, Open
ClientConnect, Open Client/Server, Open Client/Server Interfaces, Open
Gateway, Open Server, Open ServerConnect, Open Solutions, Optima++, PB-Gen,
PC APT-Execute, PC DB-Net, PC Net Library, Power++, Power AMC, PowerBuilt,
PowerBuilt with PowerBuilder, Power Dynamo, Power J, PowerScript, PowerSite,
PowerSocket, Powersoft Portfolio, PowerStudio, Power Through Knowledge,
PowerWare Desktop, PowerWare Enterprise, ProcessAnalyst, QuickStart
DataMart, QuickStart MediaMart, QuickStart ReportSmart, Replication Agent,
Replication Driver, Replication Server Manager, Report-Execute, Report
Workbench, Resource Manager, RW-DisplayLib, RW-Library, SAFE, SDF, Secure
SQL Server, Secure SQL Toolset, Security Guardian, SKILS, smart.partners,
smart.parts, smart.script, SQL Code Checker, SQL Edit, SQL Edit/TPU, SQL
Modeler, SQL Remote, SQL Server, SQL Server/CFT, SQL Server/DBM, SQL
Server Manager, SQL Server SNMP SubAgent, SQL Station, SQL Toolset, Sybase
Central, Sybase Client/Server Interfaces, Sybase Development Framework,
Sybase Gateways, Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase
SQL Workgroup, Sybase Synergy Program, Sybase Virtual Server Architecture,
Sybase User Workbench, SybaseWare, SyBooks, System 10, System 11, the System
XI logo, SystemTools, Tabular Data Stream, The Enterprise Client/Server
Company, The Future is Wide Open, The Learning Connection, The Model for
Client/Server Solutions, The Online Information Center, Translation Toolkit,
Turning Imagination Into Reality, UNIBOM, Unilib, Uninull, Unisep, Unistring,
URK Runtime Kit for UniCode, Viewer, VisualSpeller, WarehouseArchitect,
Warehouse WORKS, Watcom, Watcom SQL, Watcom SQL Server, Web.PB,
Web.SQL, WebSights, WebViewer, WorkGroup SQL Server, XA-Library, XA-
Server, and XP Server are trademarks of Sybase, Inc. 1/98
All other company and product names used herein may be trademarks or
registered trademarks of their respective companies.
Restricted Rights
Use, duplication, or disclosure by the government is subject to the restrictions set
forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for the DOD and as set forth
in FAR 52.227-19(a)-(d) for civilian agencies.
Sybase, Inc., 6475 Christie Avenue, Emeryville, CA 94608.
Table of Contents
1. Introduction
Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
About This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
Other Sources of Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
Sybase Certifications on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Javadoc Documentation of jConnect Extensions to JDBC . . . . . . . . . . . . 1-3
If You Need Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
What is JDBC? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
What is jConnect? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
2. Programming Information
jConnect Installation Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
jConnect Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
JDK 1.1 Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Invoking the jConnect Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Setting Driver Connection Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Establishing a Connection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Connecting to Adaptive Server Enterprise . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Connecting to SQL Anywhere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Setting the jConnect Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
JCONNECT_VERSION Connection Property . . . . . . . . . . . . . . . . . . 2-15
Support for SSL Security Protocol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
SSL_SOCKET_FACTORY Connection Property . . . . . . . . . . . . . . . . . . . 2-16
Creating and Configuring an SSL Socket . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
Connecting to a Server Using JNDI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
Connection URL for Using JNDI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
Required Directory Service Information . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
CONNECTION_FAILOVER Connection Property . . . . . . . . . . . . . . . . . 2-20
Providing JNDI Context Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
jConnect Character-Set Converters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
Selecting a Character-Set Converter . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
Setting the CHARSET Connection Property . . . . . . . . . . . . . . . . . . . 2-24
Improving Character-Set Conversion Performance . . . . . . . . . . . . . 2-25
Supported Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Unsupported Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
Accessing Database Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
vi Table of Contents
jConnect for JDBC version 4.0
3. Troubleshooting
Debugging with jConnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
Importing the Debug Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
Turning On Debugging in Your Application . . . . . . . . . . . . . . . . . . . . . . . 3-1
Turning Off Debugging in Your Application . . . . . . . . . . . . . . . . . . . . . . . 3-2
Setting the CLASSPATH for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Using the Debug Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Unsuccessful Connection Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
HTTP Server Address Already in Use. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Gateway Connection Refused. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Unable to Connect to a 4.9.2 SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Stored Procedure Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
RPC Returns Fewer Output Parameters Than Registered . . . . . . . . . . . . 3-5
Fetch/State Error When Stored Procedure Returns Output Params . . . 3-6
Stored Procedure Executed in Unchained Transaction Mode . . . . . . . . . 3-6
Capturing TDS Communication Between Client and Server . . . . . . . . . . . . . . . . . . . . 3-6
PROTOCOL_CAPTURE Connection Property . . . . . . . . . . . . . . . . . . . . . 3-7
pause() and resume() Methods in the Capture Class . . . . . . . . . . . . . . . . . . 3-7
Audience
This manual is for database-application programmers who are
familiar with the Java programming language, JDBC, and Transact-
SQL®, the Sybase® version of Structured Query Language.
For the latest information on product certifications and/or the EBF Rollups:
1. Point your Web browser to Technical Documents at the
following Web site:
techinfo.sybase.com
2. In the Browse section, click on the Hot entry.
3. Explore your area of interest: Hot Docs covering various topics,
or Hot Links to Technical News, Certification Reports, Partner
Certifications, and so on.
If you are not a registered SupportPlus user, and you want to become one:
You can register by following the instructions on the Web.
To use SupportPlus, you need:
• A Web browser that supports the Secure Sockets Layer (SSL),
such as Netscape Navigator 1.2 or later
1-2 Introduction
jConnect for JDBC version 4.0 If You Need Help
What is JDBC?
JDBC from JavaSoft is a specification for an application program
interface (API) that allows Java applications to access multiple
database management systems using Structured Query Language
(SQL). The JDBC driver manager handles multiple drivers that
connect to different databases.
Interface Description
java.sql.Driver Locates the driver for a database URL
java.sql.Connection Connection to a specific database
java.sql.Statement Executes SQL statements
java.sql.PreparedStatement Handles parameterized SQL statements
java.sql.CallableStatement Handles database stored procedure calls
java.sql.ResultSet Gets the results of SQL statements
java.sql.DatabaseMetaData Used to access a variety of information
about a Connection’s DBMS and database
java.sql.ResultSetMetaData Used to access a variety of information
describing a ResultSet’s attributes
What is jConnect?
The Sybase jConnect driver is both a:
• Net-protocol/all-Java driver within a three-tier environment,
and
1-4 Introduction
jConnect for JDBC version 4.0 What is jConnect?
➤ Note
Since changing the name of Sybase SQL Server™ to Adaptive Server
Enterprise, Sybase uses the names Adaptive Server and Adaptive Server
Enterprise to refer collectively to all supported versions of Sybase SQL
Server and Adaptive Server Enterprise.
1-6 Introduction
2 Programming Information 2.
➤ Note
For information about JDBC programming, visit the JavaSoft Web site. To
access JavaSoft’s JDBC Guide: Getting Started manual, go to:
http://www.javasoft.com/products/jdk/1.1/docs/guide/jdbc/
jConnect Packages
jConnect consists of the following packages in the jConnect
installation directory:
com.sybase.jdbc
com.sybase.tds
com.sybase.timedio
com.sybase.utils
The jConnect driver is in the com.sybase.jdbc package:
com.sybase.jdbc.SybDriver
You can find JDK 1.1 code samples in the sample subdirectory under
the jConnect installation directory. See “jConnect Sample Programs
and Sample Code” on page 2-63.
➤ Note
System.getProperties() is not allowed for Java applets. Use the Class.forName()
method, described below.
➤ Note
Driver connection properties set in the URL do not override any
corresponding connection properties set in the application using the
DriverManager.getConnection() method.
➤ Note
Driver connection property names are not case-sensitive. jConnect uses
the prop.equalsIgnoreCase() method to make property names case-
insensitive.
Default
Property Description
Value
APPLICATIONNAME A user-defined property. The server side can be Null
programmed to interpret the value given to this
property.
CANCEL_ALL Determines the behavior of the Statement.cancel() Depends on
method. If CANCEL_ALL is “false,” Statement.cancel() version
cancels only the Statement object it is invoked on. If setting. (See
CANCEL_ALL is “true,” Statement.cancel() cancels not “Setting the
only the object it is invoked on, but also any other jConnect
Statement objects that have already begun to execute and Version” on
are waiting for results. See “CANCEL_ALL Connection page 2-12.)
Property” on page 2-28.
CHARSET Specifies the character set for strings passed through Null
TDS. If you specify a charset, it must match a charset
listed in syscharsets.
If null, jConnect uses the server’s default charset.
Default
Property Description
Value
CHARSET_CONVERTER_ You can use this property to specify the character-set com.sybase.
CLASS converter class you want jConnect to use, either the utils.Pure-
TruncationConverter class or the PureConverter class. See Converter
“Selecting a Character-Set Converter” on page 2-23.
CONNECTION_FAILOVER For use with the Java Naming and Directory Interface true
(JNDI). When set to “true,” jConnect can make 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. See
“CONNECTION_FAILOVER Connection Property” on
page 2-20.
DYNAMIC_PREPARE Determines whether dynamic SQL prepared statements false
are precompiled in the database. If “true,” prepared
statements are precompiled, if “false,” they are sent to
the database and compiled with each use. See
“DYNAMIC_PREPARE Connection Property” on page
2-39.
EXPIRESTRING A read-only property that contains the license Never
expiration date. Expiration is “never” except for
evaluation copies of jConnect.
HOSTNAME The name of the current host. None
HOSTPROC Identifies the application’s process on the host machine. None
JCONNECT_VERSION Use this property to set version-specific characteristics. 2
See “JCONNECT_VERSION Connection Property” on
page 2-15.
LANGUAGE Set this property for error messages returned from the Depends on
server and for jConnect messages. It must match a version
language in syslanguages. setting. (See
“Setting the
jConnect
Version” on
page 2-12.)
LANGUAGE_CURSOR Set this property to true if you want jConnect to use false
“language cursors” instead of “protocol cursors.”
Protocol cursors are new in jConnect 4.0 and offer better
performance than language cursors. See “Cursor
Performance and the LANGUAGE_CURSOR
Connection Property” on page 36.
Default
Property Description
Value
LITERAL_PARAMS This property is for SQL Anywhere. false
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.
PACKETSIZE Network packet size. 512
password Login password. None
Set automatically if using the getConnection(String, String,
String) method, or explicitly if using getConnection(String,
Props).
PROTOCOL_CAPTURE The PROTOCOL_CAPTURE connection property is Null
used to specify a file for capturing TDS communication
between an application and an Adaptive Server. You
can send the file, which contains binary data and is not
directly interpretable, to Sybase Technical Support for
analysis. See “Capturing TDS Communication Between
Client and Server” on page 3-6 in Chapter 3,
“Troubleshooting.”
PROXY Gateway address. For the HTTP protocol, the URL is: None
http://host:port.
To use the HTTPS protocol that supports encryption, the
URL is https://host:port/servlet_alias.
REMOTEPWD Remote server passwords for access via DirectConnect. None
REPEAT_READ When REPEAT_READ is set to “true,” the driver keeps true
copies of columns and output parameters so that
columns can be read out of order or repeatedly. If this is
not required, more efficient performance can be
obtained by setting REPEAT_READ to “false.” See
“REPEAT_READ Connection Property” on page 2-60
SERVICENAME The name of a back-end database server that a None
DirectConnect gateway serves.
SESSION_ID When this property is set, jConnect assumes that an Null
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.
Default
Property Description
Value
SESSION_TIMEOUT Use this property to specify the amount of time (in Null
seconds) that a server connection can remain idle before
the connection is automatically closed.
SQLINITSTRING Use this property to define a set of commands to be Null
passed to the back-end database server. These must be
SQL commands that can be executed using the
Statement.executeUpdate() method.
SSL_SOCKET_FACTORY To use SSL with jConnect, set SSL_SOCKET_FACTORY Null
either to the name of a class that extends
javax.net.ssl.SSLSocketFactory and can create SSL sockets
or to “DEFAULT,” which allows you to use
javax.net.ssl.SSLSocketFactory.getDefault(). See “Support
for SSL Security Protocol” on page 2-15.
STREAM_CACHE_SIZE Maximum size used to cache statement response Null
streams. (unlimited
cache size)
USE_METADATA When set to “true” (the default setting) a true
DatabaseMetaData object will be created and initialized
when establishing a connection. The DatabaseMetaData
object is necessary for connecting to a database specified
If you do not need to connect to a database specified in
the URL or use DatabaseMetaData for application
purposes, you can set this property to “false,” which
will result in a faster connection time.
user Login ID. None
Set automatically if using the getConnection(String, String,
String) method, or explicitly if using getConnection(String,
Props).
VERSIONSTRING Read-only version information for the JDBC driver. jConnect
driver
version
Establishing a Connection
This section describes how to establish a connection to an Adaptive
Server Enterprise or SQL Anywhere database using jConnect.
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);
➤ 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 connect to SQL Anywhere via jConnect, you must run the SQL
Anywhere Open Server Gateway dbos50, which is distributed with
SQL Anywhere.
➤ Note
The free download version of SQL Anywhere available from the Powersoft
Web site does not include this Open Server Gateway. Call Powersoft at
(800) 265-4555 to receive a CD that includes the Open Server Gateway
and the required Open Server DLLs. You will be charged for shipping and
handling.
1. Install Open Server Gateway 5.5.03 or later and the Open Server
DLLs. Use Open Server DLLs, version 11.1.
2. Add an entry for the gateway to your %SYBASE%\ini\sql.ini
file (for example, with sqledit).
3. Start the gateway to the demonstration database included with
SQL Anywhere by entering:
start dbos50 gateway-demo
where gateway-demo is the gateway name defined in step 2.
4. When the Open Server gateway is running, you can define a
connection as follows:
jdbc:sybase:Tds:host:port
host is the host name where the SQL Anywhere and Open Server
gateway is running, and port is the port number defined in
sql.ini.
➤ Note
To support multiple SQL Anywhere databases, use sqledit to add an entry
with a different port for each database, then run the Open Server Gateway
for each database.
The version values are constant values from the SybDriver class. When
referring to the version constant, use the following syntax:
com.sybase.jdbc.SybDriver.VERSION_2
Use SybDriver.setVersion() to set the jConnect version. The following
code sample shows how to load the jConnect driver and set the
version to VERSION_4.
import com.sybase.jdbc.SybDriver;
import java.sql.*;
...
SybDriver d = new SybDriver();
d.setVersion(SybDriver.VERSION_4);
DriverManager.registerDriver(d);
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 the current connection.
As described in the next section, you can use the
JCONNECT_VERSION connection property to override the SybDriver
version setting and specify a different version setting for an
individual connection.
➤ Note
jConnect with SSL is for Java client applications that need to establish a
secure connection with a server. Currently, no Sybase servers support
SSL. Support is planned in future Sybase products.
"SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA"
};
Socket s =
SSLSocketFactory.getDefault().createSocket(host,
port);
((SSLSocket)s).setEnabledCipherSuites(enableThese);
return s;
}
//Additional MySSLSocketFactory methods
...
}
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.
Type of
Object Identifier (OID) Format Comments
Information
Host and port 1.3.6.1.4.1.897.4.2.5 TCP#1#hostname portnumber Multiple hosts and
ports can be specified
as separate entries.
This allows use of the
CONNECTION-
_FAILOVER
connection property.
Type of
Object Identifier (OID) Format Comments
Information
Connection 1.3.6.1.4.1.897.4.2.10 Prop1=value&Prop2=value&Prop3= Multiple connection
property value&... properties can be
specified by using a
separate entry for
each property or by
putting multiple
properties, separated
by ampersands, in a
single entry.
Database 1.3.6.1.4.1.897.4.2.11 databasename
Connection 1.3.6.1.4.1.897.4.2.9 Tds Optional. If a
protocol connection protocol
is specified, it must
always be “Tds”.
This property takes the URL of the directory service that the
driver (for example, the LDAP driver) is to access. The URL
should be a string, such as “ldap://ldaphost:427”.
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 Sun Microsystem’s 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();
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-4.
You can specify the character set to use in your application by setting
the CHARSET driver property. If you do not set the CHARSET
property:
• For VERSION_2, jConnect uses iso_1 as the default character set.
• ForVERSION_3 and VERSION_4, jConnect uses the database’s
default character set, and adjusts automatically to perform any
necessary conversions on the client side.
You can also use the -J charset command line option for the IsqlApp
application to specify a character set.
To determine which character sets are installed on your Adaptive
Server, issue the following SQL query on your server to see a list of
installed character sets:
select name from syscharsets
go
For the PureConverter class, if the designated CHARSET does not work
with the client’s Java Virtual Machine (VM), the connection fails with
a SQLException, indicating that you must set CHARSET to a character
set that is supported by both Adaptive Server and the client.
When the TruncationConverter class is used, character truncation is
applied regardless of whether the designated CHARSET is 7-bit
ASCII or not.
If you are using multibyte character sets and need to improve driver
performance, you can use the SunIoConverter class provided with the
jConnect samples. This converter is based on the sun.io classes
provided by JavaSoft.
The SunIoConverter class is not a pure Java implementation of the
character-set converter feature, and therefore is not integrated with
the standard jConnect product. However, we have provided this
converter class for your reference, and you can use it with the
jConnect driver to improve character-set conversion performance.
➤ Note
Based on Sybase testing, the SunIoConverter class improved performance
on all VMs on which it was tested. However, JavaSoft reserves the right to
remove or change the sun.io classes with future releases of the JDK, and
therefore this SunIoConverter class may not be compatible with later JDK
releases.
To use the SunIoConverter class, you must install the jConnect sample
applications. Refer to Chapter 3, “Installing jConnect 4.0,” in the
Sybase jConnect for JDBC Installation Guide and Release Bulletin for
complete instructions on installing jConnect and its components,
including the sample applications. Once the samples are installed,
you can set the CHARSET_CONVERTER_CLASS connection
property to reference the SunIoConverter class in the sample
subdirectory under your jConnect installation directory.
Table 2-5 lists the Sybase character sets that are supported by this
release of jConnect. The table also lists the corresponding JDK byte
converter for each supported character set.
➤ Note
The Sybase sjis character set does not include the IBM or Microsoft
extensions to JIS, whereas the JDK SJIS bytecode converter includes
these extensions. As a result, conversions from Java strings to a Sybase
database using sjis may result in character values that are not supported by
the Sybase database. However, conversions from sjis on a Sybase
database to Java strings should not have this problem.
The following Sybase character sets are not supported in jConnect 4.0
because no JDK byte converters are analogous to the Sybase
character sets:
• cp1047
• euccns
• greek8
• roman8
• turkish8
• ucs2
➤ Note
You cannot get metadata about temporary tables in a database.
➤ Note
The DatabaseMetaData.getPrimaryKeys() method finds primary keys
declared in a table definition (CREATE TABLE) or with alter table
(ALTER TABLE ADD CONSTRAINT). It does not find keys defined
using sp_primarykey.
➤ Note
In pre-4.0 jConnect versions, the default setting for CANCEL_ALL is “true.”
In jConnect 4.0, to comply with the JDBC specification, the default setting
for CANCEL_ALL is “false,” if you set the connection property
JCONNECT_VERSION to “4.”
➤ Note
If you want to cancel the execution of all Statement objects on a connection,
regardless of whether or not they have begun execution on the server, you
can use the extension method SybConnection.cancel().
➤ Note
jConnect implementations of JDBC 2.0 are based on the JDBC 2.0, version
0.8, draft specification. There should not be major differences between this
draft version and the final 2.0 specification, which was not available during
development of jConnect 4.0.
The current version of the JDBC 2.0 specification is available from the
JavaSoft Web site at www.JavaSoft.com.
Creating a Cursor
➤ Note
jConnect 4.0 supports forward cursors only. This is also the only cursor type
supported in JDBC 1.x.
This section discusses JDBC 2.0 methods for updating columns in the
current cursor row and updating the database from the current
cursor row in a result set. They are followed by an example.
Example
The following example creates a single Statement object which is used
to return a cursor result set. For each row in the result set, column
values are updated in memory and then the database is updated
with the row’s new column values.
// Create a Statement object and set fetch size to
// 25. This creates a cursor for the Statement
// object Use the statement to return a cursor
// result set.
SybStatement syb_stmt =
(SybStatement)conn.createStatement();
syb_stmt.setFetchSize(25);
SybCursorResultSet syb_rs =
(SybCursorResultSet)syb_stmt.executeQuery(
"SELECT * from T1 WHERE ...")
while(syb_rs.next())
{
int col3 = getInt(3);
if (col3 >100)
{
syb_rs.deleteRow();
}
}
...
}
➤ Note
There is no known advantage to setting LANGUAGE_CURSOR to “true,”
but the option is provided in case an application displays unexpected
behavior when LANGUAGE_CURSOR is “false.”
//Execute the stored procedure and get a result set from it.
SybCursorResultSet sproc_result = (SybCursorResultSet)
sproc_stmt.executeQuery();
// Move through the result set row by row, updating values in the
// cursor’s current row and updating the underlying titles table
// with the modified row values.
while(sproc_result.next())
{
sproc_result.updateString(...);
sproc_result.updateInt(...);
...
sproc_result.updateRow(titles);
}
Connection.prepareStatement()
SybConnection.prepareStatement()
Performance Tuning
If you are not concerned about portability across drivers, you can
write code that uses SybConnection.prepareStatement() to specify whether
a PreparedStatement object contains precompiled or uncompiled
statements. In this case, how you code prepared statements is likely
to depend on whether most of the dynamic statements in an
application are likely to be executed many times or only a few times
during a session.
PreparedStatement ps_uncomp =
Connection.prepareCall(sql_string);
/*
* Use set textsize to return only a single byte of column data
* to a Statement object. The packet with the column data will
* contain the "hidden" information necessary for creating a
* TextPointer object.
*/
Statement stmt= connection.createStatement();
stmt.executeUpdate("set textsize 1");
/*
* Select the column data into a ResultSet object--cast the
* ResultSet to SybResultSet because the getTextPtr method is
* in SybResultSet, which extends ResultSet.
*/
SybResultSet rs = (SybResultSet)stmt.executeQuery(getColumnData);
/*
* Position the result set cursor on the returned column data
* and create the desired TextPointer object.
*/
rs.next();
TextPointer tp = rs.getTextPtr("pic");
/*
* Now, assuming we are only updating one row, and won’t need
* the minimum textsize set for the next return from the server,
* we reset textsize to its default value.
*/
stmt.executeUpdate("set textsize 0");
The following code uses the TextPointer object from the preceding
section to update the pic column with image data in the file
Anne_Ringer.gif.
/*
* First, define an input stream for the file.
*/
FileInputStream in = new FileInputStream("Anne_Ringer.gif");
/*
* Prepare to send the input stream without logging the image data
* in the transaction log.
*/
boolean log = false;
/*
* Send the image data in Anne_Ringer.gif to update the pic
* column for author ID 899-46-2035.
*/
tp.sendData(in, log);
➤ Note
Do not confuse JDBC’s Timestamp datatype with Adaptive Server’s
timestamp datatype. The Adaptive Server timestamp datatype is a unique
varbinary value for use when updates are made using an “optimistic
concurrency” strategy.
➤ Note
When a value is inserted as a Time datatype, the date portion is essentially
meaningless, so the value should only be fetched back using a Time
datatype, never as a Date or Timestamp datatype.
// Implement SybEventHandler.event.
public void event(String eventName, ResultSet params)
{
try
{
// Check for error messages received prior to event
// notification.
SQLWarning sqlw = params.getWarnings();
if sqlw != null
{
// process errors, if any
...
}
// process params as you would any result set with
// one row.
ResultSetMetaData rsmd = params.getMetaData();
int numColumns = rsmd.getColumnCount();
while (params.next()) // optional
{
for (int i = 1; i <= numColumns; i++)
{
System.out.println(rsmd.getColumnName(i) + " =
" + params.getString(i));
}
// Take appropriate action on the event. For example,
// perhaps notify application thread.
...
}
}
catch (SQLException sqe)
{
// process errors, if any
...
}
}
}
Error-Message Handling
jConnect provides two classes for returning Sybase-specific error
information, SybSQLException and SybSQLWarning, as well as a
SybMessageHandler interface that allows you to customize the way
jConnect handles error messages received from the server.
➤ Note
Error-message handlers implementing the SybMessageHandler interface only
receive server-generated messages. They do not handle messages
generated by jConnect.
• Create a SQL warning from a SQL exception, and return it. This
results in the warning being added to the warning-message
chain.
• If the originating message is a SQL warning, messageHandler() can
evaluate the SQL warning as urgent and create and return a SQL
exception to be thrown once control is returned to jConnect.
import java.io.*;
import java.sql.*;
import com.sybase.jdbc.SybMessageHandler;
import com.sybase.jdbc.SybConnection;
import com.sybase.jdbc.SybStatement;
import java.util.*;
public MyApp()
{
try
{
Class.forName("com.sybase.jdbc.SybDriver").newInstance;
Properties props = new Properties();
props.put("user", user);
props.put("password", password);
conn = (SybConnection)
DriverManager.getConnection(server, props);
conn.setMessageHandler(new NoResultSetHandler());
stmt =(SybStatement) conn.createStatement();
stmt.executeUpdate("raiserror 20001 'your error'");
sqe.getSQLState(),sqe.getErrorCode());
}
return sqe;
}
}
➤ Note
To use the jConnect 4.0 getObject() and setObject() methods, you need to set
the jConnect version to VERSION_4. See “Setting the jConnect Version” on
page 2-12.
Friends table:
varchar(30) firstname,
varchar(30) lastname,
Address address,
varchar(15) phone
A client JDBC application can receive a Java object from the database
in a result set or as the value of an output parameter returned from a
stored procedure.
• If a result set contains a Java object as column data, you need to
use one of the following getObject() methods in the ResultSet
interface to assign the object to a class variable:
Object getObject(int columnIndex) throws SQLException;
Object getObject(String columnName) throws SQLException;
• If an output parameter from a stored procedure contains a Java
object, you need to use the following getObject() method in the
CallableStatement interface to assign the object to a class variable:
Object getObject(int parameterIndex) throws SQLException;
BigDecimal Rescaling
Compute Statements
Running IsqlApp
IsqlApp allows you to issue isql commands from the command line.
The syntax for IsqlApp is:
IsqlApp [-U username] [-P password]
[-S servername][-G gateway]
[-p http|https]
[-D debug-class-list][-v]
[-I input-command-file]
[-c command_terminator]
[-C charset] [-L language]
[-T sessionID]
[-N] [-V <version {2,3,4}>]
In this command:
-v turns on verbose printing mode.
➤ Note
You must enter a space after each option flag.
➤ Note
An applet providing GUI access to isql commands is available from
$JDBC_HOME/sample/gateway.html (UNIX) or
%JDBC_HOME%\sample\gateway.html (Windows).
Sample Applications
When you install jConnect, you can also the install sample programs.
These samples include the source code so that you can review how
➤ Note
The jConnect sample programs are intended for demonstration purposes
only.
After you install the sample programs, they are located in the sample
subdirectory under your jConnect installation directory. The file
index.html in the sample subdirectory contains a complete list of the
samples that are available with a description of each sample. In
addition, index.html lets you view and run the sample programs as
applets.
Using your Web browser, you can run the sample programs as
applets. This enables you to view the source code while viewing the
output results.
To run the samples as applets, you need to start the Cascade gateway.
See “Using the Cascade Gateway” on page A-10.
Use your Web browser to open index.html in the sample subdirectory.
http://localhost:8000/sample/index.html
All of the sample programs are compatible with Adaptive Server, but
only a limited number are compatible with SQL Anywhere. Refer to
index.html in the sample subdirectory for a current list of the sample
programs that are compatible with SQL Anywhere.
In addition, to run the sample programs that are available for SQL
Anywhere, you must install the script pubs2_any.sql on your SQL
Anywhere server. This script is located in the sample subdirectory
under your jConnect installation directory.
For Windows, go to DOS and enter:
java IsqlApp -U dba -P password
-S jdbc:sybase:Tds:[hostname]:[port]
-I %JDBC_HOME%\sample\pubs2_any.sql -c go
For UNIX, enter:
Sample Code
if (rs.next())
{
int value = rs.getInt(1);
System.out.println("Fetched value " + value);
}
}
/*
* Exception handling.
*/
Debug.debug(true,[classes],[printstream]);
The classes parameter is a string that lists the specific classes you
want to debug, separated by colons. For example:
Debug.debug(true,"MyClass")
If you include “STATIC” in the class string, it turns on debugging for
all static methods in jConnect in addition to the designated classes.
For example:
Debug.debug(true,"STATIC:MyClass")
You can specify “ALL” to turn on debugging for all classes. For
example:
Debug.debug(true,"ALL");
The printstream parameter is optional. If you do not specify a
printstream, the debug output goes to the output file you specified
with DriverManager.setLogStream().
You can add calls to other Debug methods to customize the debugging
process.
In these methods, the first (object) parameter is usually “this” to
specify the calling object. If any of these methods are static, use null
for the object parameter.
3-2 Troubleshooting
jConnect for JDBC version 4.0 Debugging with jConnect
Debug.println()
Use this method to define the message to print in the output log
if debugging is enabled and the object is included in the list of
classes to debug. The debug output goes to the output file you
specified with Debug.debug().
The syntax is:
Debug.println(object,message string);
For example:
Debug.println(this,"Query: "+ query);
produces a message similar to this in the output log:
myApp(thread[x,y,z]): Query: select * from author
Debug.assert()
Use this method to assert a condition, and throw a runtime
exception when the condition is not met. You can also define the
message to print in the output log if the condition is not met. The
syntax is:
Debug.assert(object,boolean condition,message
string);
For example:
Debug.assert(this,amount<=buf.length,amount+" too
big!");
produces a message similar to this in the output log if “amount”
exceeds the value of buf.length:
java.lang.RuntimeException:myApp(thread[x,y,z]):
Assertion failed: 513 too big!
at jdbc.sybase.utils.Debug.assert(Debug.java:338)
at myApp.myCall(myApp.java:xxx)
at .... more stack:
Debug.startTimer()
Debug.stopTimer()
Use these methods to start and stop a timer that measures the
milliseconds that elapse during an event. The method keeps one
timer per object, and one for all static methods. The syntax to
start the timer is:
Debug.startTimer(object);
The syntax to stop the timer is:
Debug.stopTimer(object,message string);
For example:
Debug.startTimer(this);
stmt.executeQuery(query);
Debug.stopTimer(this,"executeQuery");
produces a message similar to this in the output log:
myApp(thread[x,y,z]):executeQuery elapsed time =
25ms
3-4 Troubleshooting
jConnect for JDBC version 4.0 Stored Procedure Errors
If the problem persists after you have verified the hostname and port#,
you can learn more by starting the HTTP server with the “verbose”
system property enabled.
For Windows, go to a DOS prompt and enter:
httpd -Dverbose=1 > filename
For UNIX, enter:
sh httpd.sh -Dverbose=1 > filename &
where filename is the debug messages output file.
If you are not making a connection through the Cascade HTTP
gateway, your Web server probably does not support the connect
method. Applets can only connect to the host from which they were
downloaded, unless you use the Cascade HTTP gateway, which
provides a path to the database server as a proxy.
The Cascade HTTP gateway and your Web server must run on the
same host. In this scenario, your applet can connect to the same
machine/host through the port that is controlled by the Cascade
HTTP gateway, which routes the request to the appropriate database.
To see how this is accomplished, review the source of Isql.java and
gateway.html in the sample subdirectory under the jConnect
installation directory. Search for “proxy”.
jConnect uses TDS 5.0 (Sybase transfer protocol). SQL Server 4.9.x
uses TDS 4.6, which is not compatible with TDS 5.0.
SQL Server 10.0.2 or later is required for use with jConnect.
➤ Note
If you receive this error while using SQL Anywhere, you should upgrade to
SQL Anywhere version 5.5.04.
If a query does not return row data, then it should use the
CallableStatement.executeUpdate() or execute() methods rather than the
executeQuery() method.
jConnect throws a SQL exception if an executeQuery() has no result sets,
as required by the JDBC standard.
3-6 Troubleshooting
jConnect for JDBC version 4.0 Capturing TDS Communication Between Client and Server
3-8 Troubleshooting
A Web Server Gateways A.
➤ Note
jConnect 4.0 also contains support for SSL on the client system. For
information on jConnect’s client-side support of SSL, see “Support
for SSL Security Protocol” on page 2-15.
TDS tunneling
The request header indicates the length of the TDS included in the
request packet.
TDS is a connection-oriented protocol, whereas HTTP is not. In order
to support security features such as encryption for Internet
applications, jConnect uses a TDS-tunneling servlet to maintain a
logical connection across HTTP requests. The servlet generates a
session ID during the initial login request, and the session ID is
included in the header of every subsequent request. Using session
IDs lets you identify active sessions, and even resume a session as
long as the servlet has an open connection using that specific session
ID.
The logical connection provided by the TDS-tunneling servlet
enables jConnect to support encrypted communication between two
systems.
There are several options for setting up your Web servers and
Adaptive Servers. Four common configurations are described below.
These examples show where to install the jConnect driver and when
to use the Cascade gateway or a gateway with the TDS-tunneling
servlet.
Client Host
Browser
URL
Downloaded
applets and
jConnect Download Web Server
driver applets and
jConnect
applets and
jConnect
TDS 5.0
Adap-
tive
Server
With this configuration, you have a separate host for your main Web
server. A second host is shared by a Web server specifically for
Adaptive Server access and the Adaptive Server. Links from the
main server direct requests requiring SQL access to the dedicated
Web server.
• Install jConnect on the second (Adaptive Server) host.
• No gateway required.
Client Host A
Browser
URL
Downloaded
applets and Main
jConnect Web Server
driver
non-SQL
applets
URL
Download
Host B
applets and
jConnect
applets and
jConnect
Adap-
tive
Server
Client Host A
Browser
URL
Downloaded
applets and Main
jConnect Download Web Server
driver applets and
jConnect
applets and
jConnect
HTTP
tunneled TDS-TS or
TDS Cascade
Gateway
Host B
TDS 5.0
Adap-
tive
Server
Client Host A
Browser URL
Downloaded Download
applets and applets and
jConnect jConnect
driver Web Server
Supporting
HTTP/HTTPS javax.servlet
tunneled
TDS TDS servlet
applets and
jConnect
Host B
TDS 5.0
Adap-
tive
Server
Firewall
Query POST/tds?ServerHost=dbserver&ServerPort=1234&Operation=more
HTTP/1.0
Header Content-Length: 605
Content Login request
(TDS)
Client to gateway. Headers for all subsequent requests contain the session ID.
Gateway to client. Headers for all subsequent responses contain the session ID.
To use the jConnect servlet for TDS-tunneled HTTP, you need the
following:
• A Web server that supports javax.servlet interfaces. To install the
server, follow the instructions that are provided with it.
• A Web browser that supports JDK 1.1, such as Netscape 4.0,
Internet Explorer 4.0, or HotJava.
When you add the servlet to your Web server, you can enter optional
arguments to customize performance. You can enter the following
arguments:
• TdsResponseSize–Use this parameter to set the maximum TDS
packet size for the tunneled HTTPS. A larger TdsResponseSize is
more efficient if you have only a few users with a large volume of
data. Use a smaller TdsResponseSize if you have many users
making smaller transactions.
• TdsSessionIdleTimeout–Use this parameter to define the amount of
time (in milliseconds) that the server connection can remain idle
You can view information about active TDS sessions, including the
server connections for each session. Use your Web browser to open
the administrative URL:
http://host:port/TDS-servlet-path?Operation=list
For example, if your server is MYSERVER and the TDS servlet path
is /tds, you would enter:
http://myserver:8080/tds?Operation=list
This shows you a list of active TDS sessions. You can click on a
session to see more information, including the server connection.
You can use the URL described above to terminate any active TDS
session. Click on an active session from the list of sessions on the first
page, then click Terminate This Session.
➤ Note
The Cascade gateway does not support encryption, and therefore is not
suitable for Internet applications that connect to a back-end server through
a firewall.
Usage Requirements
• If you did not install jConnect in the default installation directory,
you must edit www.dos (DOS) or www.template (UNIX) and
change all default installation directory references to point to the
literal path where you installed jConnect.
• The Cascade gateway and your Web server must run on the same
host machine. This way, applets connect to the same host as the
Web server, but to the port controlled by the Cascade gateway.
The gateway routes the request to the appropriate database. To
see how this is accomplished, review the code in Isql.java and
gateway.html in the sample subdirectory of the jConnect
installation directory. Search for “proxy”.
If your database server runs on the same host as your Web server,
you do not need the Cascade gateway.
UNIX
Troubleshooting
• If you do not see a message after you enter the httpd command, the
server is not running. Retry the command in verbose mode.
For Windows, go to a DOS prompt and enter:
httpd -Dverbose=1 > filename
For UNIX, enter:
sh httpd.sh -Dverbose=1 > filename &
In these commands, filename is the output file for debug
messages.
• If you receive this error message:
HTTPServer: IOException: getRequest() Address
already in use
it means another process is running on the default port (8000).
You can:
- Stop the process that is currently running on port 8000. After
verifying that the process has terminated, try starting the
gateway.
- Change the port number in the www.dos (DOS) or www.template
(UNIX) file, located in JDBC_HOME, then modify the
gateway.html file, located in the sample subdirectory of
JDBC_HOME, by changing the PROXY parameter from
“localhost:8000” to “localhost:new_port”. If your host is not
“localhost” (which is true if your Cascade gateway and
To check your setup and test the Cascade gateway, you can run a
validation program that connects to the Sybase demonstration
database.
➤ Note
The Validate program is hardcoded to use “localhost:8000” for testing your
gateway.
Troubleshooting
Use your Web browser to view the index.html file in your jConnect
installation directory. index.html provides links to the jConnect
documentation and sample code.
➤ Note
If you use Netscape on the same machine on which you have installed
jConnect, you need to make sure that your browser does not have access
to your CLASSPATH environment variable. See “Restrictions on Setting
CLASSPATH When You Use Netscape” in Chapter 3 of the Sybase
jConnect for JDBC Installation Guide and Release Bulletin.
Troubleshooting
If you entered the correct host, port, and file information, but the
browser cannot open this link, the Cascade gateway is not running.
See “Starting the Cascade Gateway” on page A-11.
Troubleshooting
Under UNIX, if the applet does not appear as expected, you can
modify the applet screen dimensions:
The following table lists the SQL exception and warning messages
that you may encounter when using jConnect.
SQLState Message/Description/Action
010DP Duplicate connection property _____ ignored.
A connection property is defined twice. It may be defined twice in the driver
connection properties list with different capitalization, for example
“password” and “PASSWORD”. Connection property names are not case
sensitive, and therefore jConnect does not distinguish between property names
with the same name but different capitalization.
The connection property may also be defined both in the connection properties
list, as well as in the URL. In this case, the property value in the connection
property list takes precedence.
Action: Make sure your application only defines the connection property once.
However, you may want you application to take advantage of the precedence
of connection properties defined in the property list over those defined in the
URL. In this case, you can safely ignore this warning.
010MX Metadata accessor information was not found on this database. Error
encountered while attempting to retrieve metadata information: _____
The server may not have the necessary stored procedures for returning
metadata information.
Action: Make sure that stored procedures for providing metatdata are installed
on the server. See “Installing Stored Procedures” in Chapter 3 of the jConnect for
JDBC Installation Guide and Release Bulletin.
010P4 An output parameter was received and ignored.
The query you executed returned an output parameter but the application
result-processing code did not fetch it so it was ignored.
Action: If your application needs that output parameter data, you must rewrite
the application so it can get it. This may require using a CallableStatement to
execute the query, and adding calls to registerOutputParameter() and getXXX().
010SN Permission to write to file was denied. File: _____. Error message: _____
Permission to write to a file specified in the PROTOCOL_CAPTURE
connection property is denied because of a security violation in the VM. This
can occur if an applet attempts to write to the specified file.
Action: If you are attempting to write to the file from an applet, make sure that
the applet has access to the target file system.
010SP File could not be opened for writing. File: _____. Error message: _____
Action: Make sure that the file name is correct and that the file is writeable.
SQLState Message/Description/Action
010UF Attempt to execute use database command failed. Error message:_____
jConnect was unable to connect to the database specified in the connection
URL. Two possibilities are:
• The name was entered incorrectly in the URL.
• USE_METADATA is “true” (the default condition), but the stored
procedures for returning metadata have not been installed. As a result,
jConnect tried to execute the use database command with the database in the
URL, but the command failed. This may be because you attempted to access
a SQL Anywhere database. SQL Anywhere databases do not support the use
database command.
Action: Make sure the database name in the URL is correct. Make sure that the
stored procedures for returning metadata are installed on the server (see
“Installing Stored Procedures” in Chapter 3 of the jConnect for JDBC Installation
Guide and Release Bulletin). If you are attempting to access a SQL Anywhere
database, either do not specify a database name in the URL or set
USE_METADATA to “false.”
010UP Unrecognized connection property _____ ignored.
You attempted to set a connection property in the URL that jConnect does not
currently recognize. jConnect ignores the unrecognized property.
Action: Check the URL definition in your application to make sure it references
only valid jConnect driver connection properties.
010SJ Metadata accessor information was not found on this database.
The metadata information is not configured on the server.
Action: If 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 and Release
Bulletin). If you do not need metadata, set the USE_METADATA property to
“false.”
010SK Database cannot set connection option _____.
Your application attempted an operation which the database you are connected
to does not support.
Action: You may need to upgrade your database or make sure that the latest
version of MetaData information is installed on it.
JW0I0 I/O layer: thread operation failed.
An internal error occurred with a timed I/O stream.
Action: Close and reopen the connection.
JZ001 User name property ‘_____’ too long. Maximum length is 30.
Action: Do not exceed the 30 byte maximum.
SQLState Message/Description/Action
JZ002 Password property ‘_____’ too long. Maximum length is 30.
Action: Do not exceed the 30-byte maximum.
JZ003 Incorrect URL format. URL: _____
Action: These are the possible URL formats when you specify jdbc:sybase:Tds:
jdbc:sybase:Tds:host:port
jdbc:sybase:Tds:host:port/
jdbc:sybase:Tds:host:port/database
jdbc:sybase:Tds:host:port/database&property=value
In these formats:
jdbc:sybase–identifies the driver
Tds–the Sybase transfer protocol for SQL Server
host–the SQL Server host name
port–the listening port
database–use named database (preceded by a slash ‘/’)
property–a valid jConnect driver connection property name
value–value for setting the specified connection property
If you are using the PROXY connection property, you may get a JZ003
exception while trying to connect if the format for the PROXY property is
incorrect.
The PROXY format for the Cascade proxy is:
ip_address:port_number
The PROXY format for the TDS Tunneling Servlet is:
http[s]://host:port/tunneling_servlet_alias
JZ004 User name property missing in DriverManager.getConnection(..., Properties)
Action: Provide the required user property.
JZ006 Caught IOException: _____
An unexpected I/O error was detected from a lower layer. When such I/O
exceptions are caught, they are re-thrown as SQL exceptions using the
ERR_IO_EXCEPTION sqlstate. These errors are often the result of network
communication problems.
Action: Try increasing the statement cache size.
SQLState Message/Description/Action
JZ008 Invalid column index value _____.
You have requested a column index value of less than 1 or greater than the
highest available value.
Action: Check call to the getXXX() method and the text of the original query, or
be sure to call rs.next().
JZ009 Error encountered in conversion. Error message: _____
Some of the possibilities are:
• A conversion between two incompatible types was attempted, as in going
from a date to an int.
• There was an attempt to convert a string containing a non-numeric character
to a numeric type.
• There was a formatting error, such as an incorrectly formatted time/date
string.
Action: Make sure that the JDBC specification supports the attempted type
conversion. Make sure that strings are correctly formatted. If a string contains
non-numeric characters, do not attempt to convert it to a numeric type.
JZ00B Numeric overflow.
You tried to send a BigInteger as a TDS numeric, and the value was too large, or
you tried to send a Java long as an int and the value was too large.
Action: These values cannot be stored in Sybase. For long, consider using a
Sybase numeric. There is no solution for Bignum.
JZ00D getCursorName() called without a previous call to setCursorName().
You called rs.getCursorName without previously calling stmt.setCursorName.
Action: Call stmt.setCursorName before calling rs.getCursorName.
JZ00E Attempt to call execute() or executeUpdate() for a statement where
setCursorName() has been called.
Action: Don’t try to call execute or executeUpdate on a statement that has a
cursor name set. Use a separate statement to delete or update a cursor.
JZ00F Cursor name has already been set by setCursorName().
Action: Do not set the cursor name twice for a statement. Close the result set of
the current cursor statement.
JZ00G No column values were set for this row update.
Action: You attempted to update a row in which no column values were
changed. To change column values in a row, call updateXX() methods before
calling updateRow().
SQLState Message/Description/Action
JZ00H The result set is not updatable. Use Statement.setResultSetConcurrencyType().
Action: To change a result set from read-only to updatable, use the
Statement.setResultSetConcurrencyType() method or add a for update clause to your
SQL select statement.
JZ00L Login failed. Examine the SQLWarnings chained to this exception for the
reason(s).
Action: See message text; proceed according to the reason(s) given for the login
failure.
JZ010 Unable to deserialize an Object value. Error text: _____
Action: Make sure that the Java object from the database implements the
Serializable interface and is in your local CLASSPATH variable.
JZ011 Number format exception encountered while parsing numeric connection
property _____.
A non-integer value was specified for a numeric connection property.
Action: Specify an integer value for the connection property.
JZ012 Internal Error. Please report it to Sybase technical support. Wrong access type
for connection property _____.
Action: Contact Sybase Technical Support.
JZ013 Error obtaining JNDI entry: _____
Action: Correct the JNDI URL or make a new entry in the directory service.
JZ0BD Out of range or invalid value used for method parameter.
Action: Check the parameter value in the method to make sure that it is correct.
JZ0C0 Connection is already closed.
The application has already called Connection.close() on this connection object; it
cannot be used any more.
Action: Fix the code so that Connection object references are nulled out
whenever a connection is closed.
JZ0D0 This jConnect installation has not been registered yet. You need to install the
appropriate SybDriverKey classes.
Action: Go to the jConnect Web site to register your jConnect software
(http://www.sybase.com/products/internet/jconnect/). Once you register,
you can download the SybDriverKey classes necessary to activate the jConnect
driver.
SQLState Message/Description/Action
JZ0D1 Invalid SybDriverKey for this jConnect driver.
You tried accessing the jConnect driver with an activation key that does not
match the jConnect driver you are using.
Action: Go to the jConnect Web site to download a valid activation key for the
jConnect driver you are using:
http://www.sybase.com/products/internet/jconnect/.
JZ0D2 Your Sybase JDBC license expired on _____. Please obtain a new license.
Action: Contact Sybase to obtain a new license for your jConnect driver.
JZ0D3 Your Sybase JDBC license will expire soon. Please obtain a new license. It will
expire on _____.
Action: Contact Sybase to obtain a new license for your jConnect driver.
JZ0D4 Unrecognized protocol in Sybase JDBC URL:_____.
You specified a connection URL using a protocol other than TDS, which is the
only protocol currently supported by jConnect.
Action: Check the URL definition. If the URL specifies TDS as a subprotocol
make sure that the entry uses the following format and capitalization:
jdbc:sybase:Tds:host:port
If the URL specifies JNDI as a subprotocol, make sure that it starts with:
jdbc:sybase:jndi:
JZ0D5 Error loading protocol _____.
Action: Check the settings for the CLASSPATH system variable.
JZ0D6 Unrecognized version number _____ specified in setVersion. Choose one of the
SybDriver.VERSION_* values, and make sure that the version of jConnect that
you are using is at or beyond the version you specify.
Action: See message text.
JZ0D7 Error loading url provider _____. Error message: _____
Action: Check the JNDI URL to make sure it is correct.
JZ0D8 Error initializing url provider: _____
Action: Check the JNDI URL to make sure it is correct.
JZ0EM End of data.
Action: Report this error to Sybase Technical Support.
JZ0H0 Unable to start thread for event handler; event name = _____.
Action: Report this error to Sybase Technical Support.
SQLState Message/Description/Action
JZ0H1 An event notification was received but the event handler was not found; event
name = _____.
Action: Report this error to Sybase Technical Support.
JZ0HC Illegal character ‘_____’ encountered while parsing hexadecimal number.
A string that is supposed to represent a binary value contains a character that is
not in the range (0–9, a–f) that is required for a hexadecimal number.
Action: Check the character values in the string to make sure they are in the
required range.
JZ0I1 I/O Layer: Error reading stream.
The connection was unable to read the amount requested. Most likely, the
statement timeout period was exceeded and the connection timed out.
Action: Increase the statement timeout value.
JZ0I2 I/O layer: Error writing stream.
The connection was unable to write the output requested. Most likely, the
statement timeout period was exceeded and the connection timed out.
Action: Increase the statement timeout value.
JZ0I3 Unknown property. This message indicates an internal product problem.
Report this error to Sybase Technical support.
Action: Indicates an internal product problem. Report this error to Sybase
Technical Support.
JZ0I5 An unrecognized CHARSET property was specified: _____.
You specified a character set code for the CHARSET connection property that is
not supported.
Action: Enter a valid character set code for the connection property. See
“jConnect Character-Set Converters” on page 2-23.
JZ0I6 An error occurred converting UNICODE to the charset used by the server.
Error message: _____
Action: Choose a different charset code for the CHARSET connection property
on the jConnect client that can support all the characters you need to send to
the server. You may need to install a different character set on the server, too.
JZ0I7 No response from proxy gateway.
The Cascade or security gateway is not responding.
Action: Make sure the gateway is properly installed and running.
SQLState Message/Description/Action
JZ0I8 Proxy gateway connection refused. Gateway response: _____
The Web server/gateway indicated by the PROXY connection property has
refused your connection request.
Action: Check the access and error logs on the proxy to determine why the
connection was refused. Make sure the proxy is a JDBC gateway.
JZ0I9 This InputStream was closed.
You tried to read an InputStream obtained from getAsciiStream(),
getUnicodeStream(), or getBinaryStream(), but the InputStream was already closed.
The stream may have been closed because you moved to another column or
cancelled the result set and there were not enough resources to cache the data.
Action: Increase the cache size or read columns in order.
JZ0IA Truncation error trying to send_____.
There was a truncation error on charset conversion prior to sending a string.
The converted string is longer than the size allocated for it.
Action: Choose a different charset code for the CHARSET connection property
on the jConnect client that can support all the characters you need to send to
the server. You may need to install a different character set on the server, too.
JZ0IS Reading this InputStream would disable the ability to use it to update the
database.
After updating a column in a result set, you attempted to read the updated
column value using one of the following SybResultSet methods: getAsciiStream(),
getUnicodeStream(), getBinaryStream(). jConnect does not support this usage.
Action: Do not attempt to fetch input streams from columns you are updating.
JZ0J0 Offset and/or length values exceed the actual text/image length.
Action: Check the offset and/or length values you used to make sure they are
correct.
JZ0NC wasNull called without a preceding call to get a column.
You can only call wasNull() after a call to get a column, such as getInt() or
getBinaryStream().
Action: Change the code to move the call to wasNull().
JZ0NE Incorrect URL format. URL: _____. Error message: _____
Action: Check the format of the URL. Make sure that the port number consists
only of numeric characters.
JZ0NF Unable to load SSLSocketFactory. Make sure that you have spelled the class
name correctly, that the package is fully specified, that the class is available in
your class path, and that it has a public zero-argument constructor.
Action: See message text.
SQLState Message/Description/Action
JZ0P1 Unexpected result type.
The database has returned a result that the statement cannot return to the
application, or that the application is not expecting at this point. This generally
indicates that the application is using JDBC incorrectly to execute the query or
stored procedure. If the JDBC application is connected to an Open Server
application, it may indicate an error in the Open Server application that causes
the Open Server to send unexpected sequences of results.
Action: Use the com.sybase.utils.Debug(true, “ALL”) debugging tools to try to
figure out what unexpected result is seen, and to understand its causes.
JZ0P4 Protocol error. This message indicates an internal product problem. Reports
this error to Sybase technical support.
Action: Indicates an internal product problem. Report this error to Sybase
Technical Support.
JZ0P7 Column is not cached; use RE-READABLE_COLUMNS property.
With the REPEAT_READ connection property set to “false, ” an attempt was
made to reread a column or read a column in the wrong order.
When REPEAT_READ is “false.” You can only read the column value for a row
once, and you can only read columns in ascending column-index order. For
example, after reading Column 3 for a row, you cannot read its value a second
time and you cannot read Column 2 for the row.
Action: Either set REPEAT_READ to “true,” or do not attempt to reread a
column value and make sure that you read columns in ascending column-
index order.
JZ0P8 The RSMDA Column Type Name you requested is unknown.
jConnect was unable to determine the name of a column type in the
ResultSetMetaData.getColumnTypeName() method.
Action: Check to make sure that your database has the most recent stored
procedures for metadata.
JZ0P9 A COMPUTE BY query has been detected. That type of result is unsupported
and has been cancelled.
The query you executed returned COMPUTE results, which are not supported
by jConnect.
Action: Change your query or stored procedure so it does not use COMPUTE
BY.
JZ0PA The query has been cancelled and the same response discarded.
A cancel was probably issued by another statement on the connection.
Action: Check the chain of SQL exceptions and warnings on this and other
statements to determine the cause.
SQLState Message/Description/Action
JZ0PB The server does not support a requested operation.
When jConnect creates a connection with a server, it informs the server of
capabilities it wants supported and the server informs jConnect of the
capabilites that it supports. This error message is sent when an application
requests an operation that was denied in the original capabilities negotiation.
For example, if the database does not support precompilation of dynamic SQL
statements, and your code invokes SybConnection.prepareStatement(sql_stmt,
dynamic), and dynamic is set to “true,” jConnect will generate this message.
Action: Modify your code so that it does not request an unsupported
capability.
JZ0R0 Result set has already been closed.
The ResultSet.close() method has already been called on the result set object; you
cannot use the result set for anything else.
Action: Fix the code so that ResultSet object references are nulled whenever a
result set is closed.
JZ0R1 Result set is IDLE as you are not currently accessing a row.
The application has called one of the ResultSet.getXXX column-data retrieval
methods, but there is no current row; the application has not called
ResultSet.next(), or ResultSet.next() returned “false” to indicate that there is no
data.
Action: Check that rs.next() is set to “true” before calling rs.getXXX.
JZ0R2 No result set for this query.
You used Statement.executeQuery(), but the statement returned no rows.
Action: Use executeUpdate for statements returning no rows.
JZ0R3 Column is DEAD. This is an internal error. Please report it to Sybase technical
support.
Action: This is an internal code error. Contact Sybase technical support.
JZ0R4 Column does not have a text pointer. It is not a text/image column or the
column is NULL.
You cannot update a text/image column if it is NULL. A NULL text/image
column does not contain a text pointer.
Action: Make sure that you are not trying to update or get a text pointer to a
column that does not support text/image data. Make sure that you are not
trying to update a text/image column that is NULL. Insert data first, then make
the update.
SQLState Message/Description/Action
JZ0RM The last update or delete on this row was successful. The row cannot be
refreshed from the database.
After deleting a row from the database with SybCursorResult.deleteRow(), you
used SybCursorResult.getXXX() to read a column value belonging to the deleted
row in your current result set.
Action: Do not attempt to reread a column value in a result set after deleting its
row from the database.
JZ0S0 Statement state machine: Statement is BUSY.
The only time this error is raised is from the Statement.setCursorname() method,
if the application is trying to set the cursor name when the statement is already
in use and has non-cursor results that need to be read.
Action: Set the cursor name on a statement before you execute any queries on
it, or call Statement.cancel() before setting the cursor name, to make sure that the
statement isn't busy.
JZ0S1 Statement state machine: Trying to FETCH on IDLE statement.
An internal error occurred on the statement.
Action: Close the statement and open another one.
JZ0S2 Statement object has already been closed.
The Statement.close() method has already been called on the statement object;
you cannot use the statement for anything else.
Action: Fix the application so that statement object references are nulled out
whenever a statement is closed.
JZ0S3 The inherited method _____ cannot be used in this subclass.
PreparedStatement does not support executeQuery(String), executeUpdate(String), or
execute(String).
Action: If you want to pass a query string, use Statement, not PreparedStatement.
JZ0S4 Cannot execute an empty (zero-length) query.
Action: Do not execute an empty query (““).
JZ0S8 An escape sequence in a SQL Query was malformed: ‘_____’.
This error results from bad escape syntax.
Action: Check JDBC documentation for correct syntax.
JZ0S9 Cannot execute an empty (zero-length) query.
Action: Do not execute an empty query (““).
JZ0SA Prepared Statement: Input parameter not set, index: _____.
Action: Make sure that each input parameter has a value.
SQLState Message/Description/Action
JZ0SB Parameter index out of range: _____.
You have attempted to get, set, or register a parameter that goes beyond the
maximum number of parameters.
Action: Check the number of parameters in your query.
JZ0SC Callable Statement: attempt to set the return status as an InParameter.
You have prepared a call to a stored procedure that returns a status, but you are
trying to set parameter 1, which is the return status.
Action: Parameters that you can set start at 2 with this type of call.
JZ0SD No registered parameter found for output parameter.
This indicates an application logic error. You attempted to call getXXX() or
wasNull() on a parameter, but you have not read any parameters yet, or there are
no output parameters.
Action: Check to make sure that the application has registered output
parameters on the CallableStatement, that the statement has been executed,
and that the output parameters were read.
JZ0SE Invalid object type specified for setObject().
Illegal type argument passed to PreparedStatement.setObject.
Action: Check the JDBC documentation. The argument must be a constant
from java.sql.Types.
JZ0SF No Parameters expected. Has query been sent?
You tried to set a parameter on a statement with no parameters.
Action: Make sure the query has been sent before you set the parameters.
JZ0SG A CallableStatement did not return as many output parameters as the
application had registered for it.
Action: Check your stored procedures and registerOutParameter calls.
JZ0SH A static function escape was used, but the metadata accessor information was
not found on this server.
Action: Install metadata accessor information before using static function
escapes.
JZ0SI A static function escape _____ was used which is not supported by this server.
Action: Do not use this escape.
JZ0SJ Metadata accessor information was not found on this database.
Action: Install metadata information before making metadata calls.
JZ0SM Unsupported SQL type _____.
Action: Do not use Types.NULL, Types.OTHER, or PreparedStatement.setObject(null)
SQLState Message/Description/Action
JZ0SN setMaxFieldSize: field size cannot be negative.
Action: Use a positive value or zero (unlimited) when calling setMaxFieldSize.
JZ0T2 Listener thread read error.
Action: Check your network communications.
JZ0T3 Read operation timed out.
The time allotted to read the response to a query was exceeded.
Action: Increase the timeout period by calling Statement.setQueryTimeout().
JZ0T4 Write operation timed out. Timeout in milliseconds: _____.
The time allotted to send a request was exceeded.
Action: Increase the timeout period by calling Statement.setQueryTimeout().
JZ0T5 Cache used to store responses is full.
Action: Use default or larger value for the STREAM_CACHE_SIZE connection
property.
JZ0T6 Error reading tunneled TDS URL.
The tunneled protocol failed while reading the URL header.
Action: Check the URL you defined for the connection.
JZ0T7 Listener thread read error -- caught ThreadDeath. Check network connection.
Action: Check the network connections and try to run the application again. If
the threads continue to be aborted, contact Sybase Technical Support.
JZ0T9 Request to send not synchronized. Please report this error to Sybase Technical
Support.
Action: Report the error to Sybase Technical Support.
JZ0TC Attempted conversion between an illegal pair of types.
Conversion between a Java type and a SQL type failed.
Action: Check the requested type conversion to make sure it is supported in
the JDBC specification.
JZ0US The SSL_SOCKET_FACTORY connection property was set, and the PROXY
connection property was set to the URL of a servlet. The jConnect driver does
not support this combination. If you want to send secure HTTP from an applet
running within a browser, use a proxy URL beginning with “https://”.
Action: See message text.
S0022 Invalid column name ‘_____’.
You attempted to reference a column by name and there is no column with that
name.
Action: Check the spelling of the column name.
SQLState Message/Description/Action
ZZ00A The method _____ has not been completed and should not be called.
You have attempted to use a method that is not implemented.
Action: Check the release bulletin that came with your version of jConnect for
further information. You can also check the jConnect Web page at
http://www.sybase.com to see whether a more recent version of jConnect
implements the method. If not, do not use the method.