

SQL Anywhere 12.0.1 » SQL Anywhere Server - Programming » JDBC support » Connections from a JDBC client application


Running the connection example

 Create and execute the external connection example application
  1. At a command prompt, change to the %SQLANYSAMP12%\SQLAnywhere\JDBC directory.


    dbsrv12 "%SQLANYSAMP12%\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=.;%SQLANY12%\java\sajdbc4.jar

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

    set classpath=.;%SQLANY12%\java\sajdbc.jar


    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 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 a 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.