15-8. Creating and Calling a Java Database Function

Problem

You want to create a database function using the Java language.

Solution

Create a function written in Java, and then create a call specification for the function. Ensure that the call specification allows for the same number of parameters to pair up with the Java function and allows for a returning result. For this recipe, you will add a function to the Employees Java class that will accept an employee ID and return that employee's job title. The following code is the Java source for the function named getEmpJobTitle:

public static String getEmpJobTitle(int empId){       String jobTitle = null;       try {            Connection conn = DriverManager.                         getConnection("jdbc:default:connection:"); ...

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

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