SQL Anywhere JDBC Driver Connection Strings

To connect to a database via a SQL Anywhere JDBC driver, you need to supply a URL for the database. For example:

Connection con = DriverManager.getConnection(
      "jdbc:sqlanywhere:DSN=Sybase IQ Demo" );
Connection con = DriverManager.getConnection("jdbc:sqlanywhere:DSN=Sybase IQ Demo" );

The URL contains jdbc:sqlanywhere: followed by a connection string. If the sajdbc4.jar file is in your class file path, then the JDBC 4.0 driver will have been loaded automatically and it will handle the URL. As shown in the example, an ODBC data source (DSN) may be specified for convenience, but you can also use explicit connection parameters, separated by semicolons, in addition to or instead of the data source connection parameter.

If you do not use a data source, you must specify all required connection parameters in the connection string:

Connection con = DriverManager.getConnection(
      "jdbc:sqlanywhere:UserID=<user_id>;Password=<password>;Start=..." );

The Driver connection parameter is not required since neither the ODBC driver nor ODBC driver manager is used. If present, it will be ignored.