Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » Tutorial: Using Java in the Database » Introduction to Java in the Database tutorial

Using the CLASSPATH variable Next Page

Accessing methods in the Java class

To access the Java methods in the class, you must create stored procedures or functions that act as wrappers for the methods in the class.

To call a Java method using Interactive SQL
  1. Create the following SQL stored procedure to call the Invoice.main method in the sample class:

    CREATE PROCEDURE InvoiceMain( IN arg1 CHAR(50) )
    EXTERNAL NAME 'Invoice.main([Ljava/lang/String;)V'

    This stored procedure acts as a wrapper to the Java method.

    For more information about the syntax of this command, see CREATE PROCEDURE statement.

  2. Call the stored procedure to call the Java method:

    CALL InvoiceMain('to you');

    If you examine the database server console or Server Messages window, you see the message "Hello to you" written there. The database server has redirected the output there from System.out.