To create and execute the internal connection example application
At a command prompt, change to the samples-dir\SQLAnywhere\JDBC directory.
Start a database server with the sample database on your local computer using the following command:
dbeng11 samples-dir\demo.db |
For server-side JDBC, it is not necessary to set the CLASSPATH environment variable.
Enter the following command to compile the example:
javac JDBCConnect2.java |
Install the class into the sample database using Interactive SQL. Run the following statement:
INSTALL JAVA NEW FROM FILE 'samples-dir\SQLAnywhere\JDBC\JDBCConnect2.class' |
You can also install the class using Sybase Central. While connected to the sample database, open the Java subfolder under External Environments and choose File » New » Java Class. Then follow the instructions in the wizard.
Define a stored procedure named JDBCConnect that acts as a wrapper for the JDBCConnect2.main method in the class:
CREATE PROCEDURE JDBCConnect() EXTERNAL NAME 'JDBCConnect2.main([Ljava/lang/String;)V' LANGUAGE JAVA; |
Call the JDBCConnect2.main method as follows:
call JDBCConnect(); |
The first time a Java class is called in a session, the Java VM must be loaded. This might take a few seconds.
Confirm that a list of identification numbers with customers' names appears in the database server messages window.
If the attempt to connect fails, an error message appears instead. Confirm that you have executed all the steps as required.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |