Using the command main method

In a Java client, you typically begin Java applications by running the Java Virtual Machine (VM) on the command main method of a class. The JDBCExamples class, for example, contains a main method. When you execute the class from the command line as in the following:

java JDBCExamples

it is the command main method that executes.

NoteYou cannot reference a Java main method in a SQLJ create function statement.

If you reference a Java main method in a SQLJ create procedure statement, the command main method must have the Java method signature String[] as in:

public static void main(java.lang.String[]) {
...
}

If the Java method signature is specified in the create procedure statement, it must be specified as (java.lang.String[]). If the Java method signature is not specified, it is assumed to be (java.lang.String[]).

If the SQL procedure signature contains parameters, those parameters must be char, unichar, varchar, or univarchar. At runtime, they are passed as a Java array of java.lang.String.

Each argument you provide to the SQLJ procedure must be char, unichar, varchar, univarchar, or a literal string because it is passed to the main method as an element of the java.lang.String array. You cannot use the dynamic result sets clause when creating a main procedure.