JDBC drivers

SQL Anywhere supports the following JDBC drivers:

  • SQL Anywhere JDBC 3.0 driver   This driver communicates with SQL Anywhere using the Command Sequence client/server protocol. Its behavior is consistent with ODBC, embedded SQL, and OLE DB applications. The SQL Anywhere JDBC 3.0 driver can be used only with JRE 1.4 or later. Note that the SQL Anywhere JDBC 4.0 driver is recommended for applications using JRE 1.6 or later.

  • SQL Anywhere JDBC 4.0 driver   This driver communicates with SQL Anywhere using the Command Sequence client/server protocol. Its behavior is consistent with ODBC, embedded SQL, and OLE DB applications. The SQL Anywhere JDBC 4.0 driver is the recommended JDBC driver for connecting to SQL Anywhere databases. The JDBC 4.0 driver can be used only with JRE 1.6 or later.

    It is strongly recommended that applications using JRE 1.6 or later switch to the JDBC 4.0 driver instead of continuing to use the JDBC 3.0 driver. The JDBC 4.0 driver takes advantage of the new automatic JDBC driver registration. Hence, if an application wants to make use of the JDBC 4.0 driver, it no longer needs to perform a Class.forName call to get the JDBC driver loaded. It is instead sufficient to have the sajdbc4.jar file in the class file path and simply call DriverManager.getConnection() with a URL that begins with jdbc:sqlanywhere.

    The JDBC 4.0 driver contains manifest information to allow it to be loaded as an OSGi (Open Services Gateway initiative) bundle.

    With the JDBC 4.0 driver, metadata for NCHAR data now returns the column type as java.sql.Types.NCHAR, NVARCHAR, or LONGNVARCHAR. In addition, applications can now fetch NCHAR data using the Get/SetNString or Get/SetNClob methods instead of the Get/SetString and Get/SetClob methods.

  • jConnect   This driver is a 100% pure Java driver. It communicates with SQL Anywhere using the TDS client/server protocol.

    jConnect and jConnect documentation are available at [external link] http://www.sybase.com/products/allproductsa-z/softwaredeveloperkit/jconnect.

When choosing which driver to use, you should consider the following factors:

  • Features   The SQL Anywhere JDBC 3.0 driver is JDBC 3.0 compliant. The SQL Anywhere JDBC 4.0 driver and jConnect are JDBC 4.0 compliant. Both versions of the SQL Anywhere JDBC driver provide fully-scrollable cursors when connected to a SQL Anywhere database. The jConnect JDBC driver provides scrollable cursors when connected to a SQL Anywhere database server, but the result set is cached on the client side. The jConnect JDBC driver provides fully-scrollable cursors when connected to an Adaptive Server Enterprise database.

    The JDBC 3.0 and 4.0 API documentation is available at [external link] http://www.oracle.com/technetwork/java/download-141179.html. For a summary of the JDBC API methods supported by the SQL Anywhere JDBC driver, see JDBC 3.0/4.0 API support.

  • Pure Java   The jConnect driver is a pure Java solution. The SQL Anywhere JDBC drivers are based on the SQL Anywhere ODBC driver and are not pure Java solutions.

  • Performance   The SQL Anywhere JDBC drivers provide better performance for most purposes than the jConnect driver.

  • Compatibility   The TDS protocol used by the jConnect driver is shared with Adaptive Server Enterprise. Some aspects of the driver's behavior are governed by this protocol, and are configured to be compatible with Adaptive Server Enterprise.

For information about platform availability for the SQL Anywhere JDBC drivers and jConnect, see [external link] http://www.sybase.com/detail?id=1061806.

 See also