Contents Index How the server-side connection example works Notes on JDBC connections

ASA Programming Guide
  JDBC Programming
    Establishing JDBC connections
      Establishing a connection from a server-side JDBC class

Running the server-side connection example

This section describes how to run the server-side connection example.

To create and execute the internal connection example application

  1. If you have not already done so, compile the JDBCExamples.java file. If you are using the JDK, you can do the following in the Samples\ASA\Java directory from a command prompt:

    javac JDBCExamples.java
  2. Start a database server using the sample database. You can start such a server on your local machine using the following command (from the Samples\ASA\Java subdirectory):

    start dbeng9 ..\..\..\asademo

    The TCP/IP network protocol is not necessary in this case since you are not using jConnect.

  3. Install the class into the sample database. Once connected to the sample database, you can do this from Interactive SQL using the following command:

    INSTALL JAVA NEW
    FROM FILE 'path\Samples\ASA\Java\JDBCExamples.class'

    where path is the path to your installation directory.

    You can also install the class using Sybase Central. While connected to the sample database, open the Java Objects folder and choose File > New > Java Class. Then follow the instructions in the wizard.

  4. You can now call the InternalConnect method of this class just as you would a stored procedure:

    CALL JDBCExamples>>InternalConnect()

    The first time a Java class is called in a session, the internal Java virtual machine must be loaded. This can take a few seconds.

  5. Confirm that the message Hello World prints on the server screen.


Contents Index How the server-side connection example works Notes on JDBC connections