Java Stored Procedure Example

Nothing speaks to a programmer more clearly than code. Let the example that I'm going to present serve as a guide to begin understanding how Java stored procedures work. You will see an Oracle header to the Java code shown in Listing 4-1 in bold font. And you will also observe the definition of an Oracle function, following the Java code, which encapsulates the Java code. You cannot call Java code directly from an Oracle query, but you can call the Oracle function or procedure which will then call and run the Java.

Place a bookmark here so you can refer back Listing 4-1 in the discussion that follows. We will load this code into the Oracle database shortly.

Listing 4-1. MyApp4 and f_get_oracle_time

SET ROLE appsec_role; ...

Get Expert Oracle and Java Security: Programming Secure Oracle Database Applications with Java now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.