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

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » JDBC support » SQL Anywhere JDBC drivers


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=SQL Anywhere 16 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=DBA;Password=sql;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.

 See also