At a command prompt, change to the %SQLANYSAMP12%\SQLAnywhere\JDBC directory.
Start a database server with the sample database on your local computer using the following command:
dbeng12 "%SQLANYSAMP12%\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. Execute the following statement:
INSTALL JAVA NEW FROM FILE '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 click 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(OUT args LONG VARCHAR) 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.
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |