Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.0 (Français) » SQL Anywhere Server - Programming » JDBC support

 

Choosing a JDBC driver

SQL Anywhere supports the following JDBC drivers:

  • 3.0 SQL Anywhere JDBC 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.

  • 4.0 SQL Anywhere JDBC 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 4.0 SQL Anywhere JDBC 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.

    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   Both the 3.0 SQL Anywhere JDBC driver and jConnect 6.0.5 are JDBC 3.0 compliant and the 4.0 SQL Anywhere JDBC driver is JDBC 4.0 compliant. However, both versions of the SQL Anywhere JDBC driver provide fully-scrollable cursors when connected to a SQL Anywhere database. The jConnect JDBC driver provides fully-scrollable cursors only when connected to an Adaptive Server Enterprise database.

    The JDBC 3.0 and 4.0 API documentation is available at [external link] http://java.sun.com/products/jdbc/download.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.

For information about using jConnect with Windows Mobile, see Using jConnect on Windows Mobile.