You typically start Java applications (outside the database) by running the Java VM on a class that has a main method.
For example, the Invoice class in the file samples-dir\SQLAnywhere\JavaInvoice\Invoice.java has a main method. When you execute the class from the command line using a command such as the following, it is the main method that executes:
java Invoice |
To call the main method of a class from SQL
Declare the method with an array of strings as an argument:
public static void main( java.lang.String args[] ) { ... } |
Create a stored procedure that wraps this method.
CREATE PROCEDURE JavaMain( in arg char(50) ) EXTERNAL NAME 'JavaClass.main([Ljava/lang/String;)V' LANGUAGE JAVA; |
For more information, see CREATE PROCEDURE statement.
Invoke the main method using the CALL statement.
call JavaMain( 'Hello world' ); |
Due to the limitations of the SQL language, only a single string can be passed.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |