Switch to standard view 
  Sybase logo
 
 
 




5. Migrating jConnect Applications

This chapter explains how to migrate applications that use Sybase extensions from jConnect version 4.0 or earlier to use jConnect versions 4.1 and later. The following topics are covered:

Overview


A new package, com.sybase.jdbcx, has been added to jConnect versions 4.1 and 5.0 that contains all of the Sybase extensions to JDBC. In previous versions of jConnect, these extensions were available in the com.sybase.jdbc and com.sybase.utils packages.

The new package provides a consistent interface across different versions of jConnect. All of the Sybase extensions are defined as Java interfaces, which allows the underlying implementations to change without affecting applications built using these interfaces.

When you develop new applications that use Sybase extensions, use com.sybase.jdbcx. The interfaces in this new package allow you to upgrade applications to versions of jConnect that follow version 5.0 with minimal changes.

Note

Applications previously built using the Sybase extensions to the JDBC API, which were available in com.sybase.jdbc and com.sybase.utils, will continue to work under jConnect 4.1; however, all Sybase extensions in com.sybase.jdbc and com.sybase.utils have been marked deprecated.
Migrating Applications to jConnect 4.1


jConnect 4.1 is backward compatible with previous versions of jConnect. All existing applications should continue working without recompiling.

When you develop new applications that use Sybase extensions, use the interfaces located in com.sybase.jdbcx.

This common interface allows you to upgrade applications to jConnect 5.0 with minimal changes. See "Sybase Extension Changes" for changes made in the Sybase extensions. For example, if an application uses the SybMessageHandler, the code differences would be:

  • jConnect 4.0 code:
      
import com.sybase.jdbc.SybConnection;
import com.sybase.jdbc.SybMessageHandler;
.
.
Connection con = DriverManager.getConnection(url, props); 
SybConnection sybCon = (SybConnection) con; 
sybCon.setMessageHandler(new ConnectionMsgHandler());
  • jConnect 4.1/5.0 code:
      
import com.sybase.jdbcx.SybConnection;
import com.sybase.jdbcx.SybMessageHandler;
.
.
Connection con = DriverManager.getConnection(url, props);
SybConnection sybCon = (SybConnection) con;
sybCon.setSybMessageHandler(new ConnectionMsgHandler());

See the samples provided with jConnect for more examples of how to use Sybase extensions.

Migrating Applications to jConnect 5.0


The package and classes for the Sybase jConnect 5.0 Driver Manager is com.sybase.jdbc2.jdbc.SybDriver. This is different from previous versions of jConnect. Applications need to change their source code where they load SybDriver and recompile with the JavaTM 2 Platform.

Here is an example of loading the driver in jConnect 5.0:

      
Driver d =
(Driver)Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
DriverManager.registerDriver(d);

If your applications use Sybase extensions to the JDBC API, change your imports from using com.sybase.jdbc and/or com.sybase.utils to com.sybase.jdbcx. See "Sybase Extension Changes" for changes made to the Sybase extensions.

See the samples provided with jConnect for more examples of how to use Sybase extensions.

Sybase Extension Changes


Some of the Sybase extensions have been changed to accommodate the new com.sybase.jdbcx interface.

Changed Method Names


The following table lists how methods have been renamed in the new interface.

Class

Old Name

New Name

SybConnection

getCapture

createCapture

SybConnection

setMessageHandler

setSybMessageHandler

SybConnection

getMessageHandler

getSybMessageHandler

SybStatement

setMessageHandler

setSybMessageHandler

SybStatement

getMessageHandler

getSybMessageHandler

Debug Class


Direct static references to the Debug class are no longer supported, but exist in deprecated form in the com.sybase.utils package. To use jConnect debugging facilities, use the getDebug( ) method of the SybDriver class to obtain a reference to the Debug class. For example:

      
import com.sybase.jdbcx.SybDriver;
import com.sybase.jdbcx.Debug;
.
.
.
SybDriver sybDriver =
(SybDriver)Class.forName("com.sybase.jdbc2.jdbc.SybDriver").
        newInstance();
Debug sybDebug = sybDriver.getDebug();
sybDebug.debug(true, "ALL", System.out);

A complete list of Sybase extensions is in the jConnect javadoc documentation located in the docs/ directory of your jConnect installation directory.


Sybase(R) jConnect for JDBC(TM) Programmer's Reference - 29 Jan 1999

Copyright 1999 © Sybase, Inc. All Rights Reserved.


Back to Top
© Copyright 2010, Sybase Inc.