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 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.