Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 

I originally posted this a few years ago to help people configure their Java applications to use the iAnywhere JDBC driver, which was replaced by the SQL Anywhere JDBC driver in SQL Anywhere version 12.  I am reposting it here with a few minor updates, since I still refer to it occasionally and I think it is still useful.

I have heard from customers that connecting to SQL Anywhereover JDBC can be difficult at times.  In my investigations of this, I have found that this is almost always due to confusion over the classname to use to register the JDBC driver, and the URL's to use to actually connect to the database.  In stepping back, I can see how people might easily get confused based on the history of the JDBC driver.  Here is my attempt to clarify things by following the history of the driver, starting with SQL Anywhere version 9.

Before I go into detail on the history of the SQL Anywhere JDBC driver, here is a table which explains classpath settings, jar files required, driver name URLs and sample connection URLs.

SQL Anywhere VersionJDBC jar file to include in classpathDriver classnameConnection URL
9.0.2%ASA90%\java\ Server Anywhere 9.0;UID=DBA;PWD=sql;eng=demo
10.0.0%SQLANY10%\java\ Anywhere 10 Demo;UID=DBA;PWD=sql;eng=demo
10.0.1%SQLANY10%\java\ Anywhere 10;DSN= SQL Anywhere 10 Sample
11.0.0%SQLANY11%\java\ Anywhere 10;DSN= SQL Anywhere 11 Sample
12.0.0%SQLANY12%\java\sajdbc4.jarno longer required for JDBC 4.0jdbc:sqlanywhere:uid=DBA;pwd=sql;eng=demo
16.0%SQLANY16%\java\sajdbc4.jarno longer required for JDBC 4.0jdbc:sqlanywhere:uid=DBA;pwd=sql;eng=demo

  1. Adaptive Server Anywhere version 9.0 (aka SQL Anywhere 9.0)
    In version 9, SQL Anywhere supported JDBC 2.0 using an iAnywhere generic JDBC-ODBC bridge driver (similar to but different from the Sun JDBC/ODBC driver).  The jar file is jodbc.jar, and resides in the %ASA90%\java directory.  To use the iAnywhere JDBC driver, you need to include the jar in your classpath.  Then, you need to register it in your java app using the following code:

        (Driver)Class.forName( "" ).newInstance() );

    Since the iAnywhere JDBC/ODBC driver is a bridge driver, to connect to your SQL Anywhere database, you need to specify a "DRIVER=" parameter along with the rest of your connect string.  For example:

    Connection con = DriverManager.getConnection(
        "jdbc:odbc:Driver=Adaptive Server Anywhere 9.0;UID=DBA;PWD=sql;eng=demo" );

    or, you could use an ODBC data source like this:

    Connection con = DriverManager.getConnection(
        "jdbc:odbc:DSN= Adaptive Server Anywhere 9.0 Sample" );

  2. SQL Anywhere 10.0.0
    In version 10, we added support for JDBC 3.0.  To use the version 10 iAnywhere JDBC/ODBC bridge driver, you need to again include %SQLANY10%\java\jodbc.jar in your classpath.  However, the class name for driver registration is slightly different:

        (Driver)Class.forName( "" ).newInstance() );
    Once registered, the connection URL was the same as in verison 9, above.

  3. SQL Anywhere 10.0.1
    After version 10 was released, we noticed that in some customer issues involving JDBC, the iAnywhere driver was not always being loaded when it was supposed to be, particularly when the Sun JDBC/ODBC bridge driver was present.  It turns out that our use of "jdbc:odbc" in the connection URL was not sufficient to guarantee that the iAnywhere driver would be used during a connection.  If the Sun bridge were present, it could be picked up and used instead, which lead to all sorts of unexpected behaviour. To resolve this problem, the 10.0.1 maintenance release introduced a new URL header for the iAnywhere driver, "jdbc:ianywhere".  From this point forward, the URL to register the driver was the same as with v10, but the correct URL to use when connecting to the database was as follows:

    Connection con = DriverManager.getConnection(
        "jdbc:ianywhere:Driver=SQL Anywhere 10;DSN= SQL Anywhere 10 Sample" );
    The "jdbc:ianywhere" portion of the connection string was actually back-ported to a 9.0.1 ebf, so if you are running one of the later 9.0.1 or 9.0.2 ebfs, the above connection URL will work for you as well.

  4. SQL Anywhere version 11.0.0
    In SQL Anywhere version 11, there was no change in classname for the driver or URL for the connection string, but we did update to a newer version of the JDK. This meant we had to drop the JDBC 2.0 driver, because JDK 1.4 and newer no longer supported it.  To make things easier for our customers, we kept the JDBC 2.0 class names in the version 10 JDBC 3.0 jar.  They simply pointed to the JDBC 3.0 equivalents.

  5. SQL Anywhere 11.0.1
    In SQL Anywhere version 11.0.1, a new SQL Anywhere JDBC driver was introduced.  No longer a generic iAnywhere JDBC driver, it is a JDBC driver specific to SQL Anywhere.  This was done to make it easier (ie. less confusing) for people to use JDBC with SQL Anywhere.  With the new driver, there is no need to install ODBC on the system.  This wasn't a problem for Windows, but our Linux and Unix customers often had problems with this.  As an added bonus, the performance of the driver was improved slightly because we no longer have to go through the ODBC driver manager. This change involved adding 2 new files to the SQL Anywhere installation:  sajdbc.jar and dbjdbc11.dll. To use the new driver, you need to include %SQLANY11%\java\sajdbc.jar in your classpath.  Then, the driver registration is as follows:

       (Driver) Class.forName( "sybase.jdbc.sqlanywhere.IDriver" ).newInstance() );
    Then, to connect, you use the following URL:

    Connection con = DriverManager.getConnection(
        "jdbc:sqlanywhere:uid=DBA;pwd=sql;eng=demo" );
  6. SQL Anywhere 12/16
    SQL Anywhere 12 deprecated the use of the iAnywhere JDBC/ODBC bridge driver in favor of the new SQLAnywhere driver.  In addition, SQL Anywhere 12 will support JDBC 4.0 (which requires JDK 1.6 or newer). To continue to use the JDBC 3.0, users do not have to make any changes from previous versions.  However, to use the JDBC 4.0 support, the new driver name is "sybase.jdbc4.sqlanywhere.IDriver", and requires that %SQLANY12%\java\sajdbc4.jar be in your classpath. However, there is no need to call DriverManager.registerDriver(...) to register the driver before using it anymore.  Sun has implemented automatic driver registration so that applications just need to make sure that sajdbc4.jar is in the classpath (and dbjdbc12.dll is in the path), and use the "jdbc:sqlanywhere" URL header to connect.  So, to connect with SQL Anywhere 12 and JDBC 4.0, all you need is something like the following line of code:

    Connection con = DriverManager.getConnection(
        "jdbc:sqlanywhere:uid=DBA;pwd=sql;eng=demo" );

That concludes our history lesson. Confused yet?