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 » Connections from a JDBC client application


Running the connection example

The steps involved in creating and executing a JDBC application are shown through the use of an example.


A Java Development Kit (JDK) must be installed.

Contexte et remarques

Two different types of connections using JDBC can be made. One is the client-side connection and the other is the server-side connection. The following example uses a client-side connection.

  1. At a command prompt, change to the %SQLANYSAMP16%\SQLAnywhere\JDBC directory.

  2. Start a database server with the sample database on your local computer using the following command:

    dbsrv16 "%SQLANYSAMP16%\demo.db"
  3. Set the CLASSPATH environment variable. The SQL Anywhere JDBC 4.0 driver contained in sajdbc4.jar is used in this example.

    set classpath=.;%SQLANY16%\java\sajdbc4.jar

    If you are using the jConnect driver instead, then use the following (where path is your jConnect installation directory):

    set classpath=.;jconnect-path\classes\jconn4.jar
  4. Run the following command to compile the example:

  5. Run the following command to execute the example:

    java JDBCConnect

    Add a command line argument such as jconnect to load a different JDBC driver.

    java JDBCConnect jconnect
  6. Confirm that a list of identification numbers with customer names appears at the command prompt.

    If the attempt to connect fails, an error message appears instead. Confirm that you have executed all the steps as required. Check that your class file path is correct. An incorrect setting may result in a failure to locate a class.


A list of identification numbers with customer names is displayed.