15-2. Loading a Java Database Class into a Database

Problem

You want to load a Java class into a schema within your Oracle Database.

Solution #1

You can use the CREATE JAVA command to load the Java source into the database by copying and pasting the Java source into a SQL file. This is the easiest way to create a Java class and then load it into the database if you are not working directly on the database server but rather remotely using an editor or SQL*Plus. The following lines of SQL code will load the Java class that was created in Recipe 15-1 into the database using the CREATE JAVA command:

CREATE OR REPLACE JAVA SOURCE NAMED "Employees" AS import java.sql.*; import oracle.jdbc.*; public class Employees {   public static void getItEmps(){ ...

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.