Before you can create a Java™ stored
procedure from a method, you must refactor the code in the method
so that it can be invoked as a stored procedure.
About this task
The method from which you want to create the Java stored procedure must be a valid entry
point for the stored procedure. Specifically, the method must meet
the following requirements:
- The method must be defined as a public static void method
- The database connection in the method must be defined as jdbc:default:connection.
- Any data returned by the method must be returned in a single-element
array.
- If the method handles checked exceptions, the exceptions should
not be resolved in the method. Exceptions must be passed back to the
invoker through a throws clause.
If you are working with a pureQuery-enabled Java project, you must meet additional refactoring
requirements. See the sample code for the following cases:
- Returning a result set from a method in a pureQuery application
that uses inline methods
- Returning an OUT parameter from a method in a pureQuery application
that uses annotated methods
- Returning a param from a method, based on a pureQuery application
that uses annotated methods and runs SQL statements dynamically
Tip: Meeting all of the requirements for the Java stored procedure entry point might require
significant changes to the method code. Instead of refactoring the
code of the actual method, consider creating a copy of the method
and using it as the stored procedure entry point.
To
refactor the method code: