Running the connection example

 To create and execute the external connection example application
  1. At a command prompt, change to the samples-dir\SQLAnywhere\JDBC directory.

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

    dbsrv12 samples-dir\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=.;install-dir\java\sajdbc4.jar

    If you are using the SQL Anywhere JDBC 3.0 driver instead, then use the following:

    set classpath=.;install-dir\java\sajdbc.jar

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

    set classpath=.;path\jConnect-6_0\classes\jconn3.jar
  4. Run the following command to compile the example:

    javac JDBCConnect.java
  5. Run the following command to execute the example:

    java JDBCConnect

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

    java JDBCConnect jconnect
  6. Confirm that a list of identification numbers with customer's 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.