16-1. Accessing a PL/SQL Stored Procedure via JDBC


You are writing a Java application that uses JDBC to access data, but you also want to call some PL/SQL stored procedures from within your Java application.


Use the JDBC API to connect to the database, and then execute prepareCall(), passing a string to it that consists of a PL/SQL code block that calls the stored procedure. For example, consider a stand-alone Java class that contains a method named increaseWage(). This method uses JDBC to obtain a database connection, create a CallableStatement, and then invoke the PL/SQL stored procedure that passes in the required variables.

import java.sql.*; import oracle.jdbc.*; public class EmployeeFacade {  public void increaseWage() ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.