Oracle Database 10g introduces the native Java interface--new features for calls to server-side Java code. It is a simplified application integration: client-side (and middle-tier) Java applications can directly invoke Java in database without the need for defining a PL/SQL wrapper. Uses server-side Java class reflection capability.
In previous releases, calling Java stored procedures and functions from a database client required JDBC calls to associated PL/SQL wrappers. Each wrapper had to be manually published with a SQL signature and a Java implementation. This had the following disadvantages:
- The signatures permitted only Java types that had direct SQL equivalents.
- Exceptions issued in Java were not properly returned.
The JPublisher -java option provides functionality to avoid these disadvantages. To remedy the deficiencies of JDBC calls to associated PL/SQL wrappers, the
-javaoption makes convenient use of an API for direct invocation of static Java methods. This functionality is also useful for Web services.
The functionality of the
-javaoption mirrors that of the -sql option, creating a client-side Java stub class to access a server-side Java class, as opposed to creating a client-side Java class to access a server-side SQL object or PL/SQL package. The client-side stub class uses JPublisher code that mirrors the server-side class and includes the following features:
- Methods corresponding to the public static methods of the server class
- Two constructors: one that takes a JDBC connection and one that takes the JPublisher default connection context instance
At runtime, the stub class is instantiated with a JDBC connection. Calls to its methods result in calls to the corresponding methods of the server-side class. Any Java types used in these published methods must be primitive or serializable.
As an example, assume you want to call the following method in the server:
Use the following