Oracle can use multiple languages to write stored procedures, such as Pro*c/c++,pl/sql,cobol, and in oracle8i to support writing stored procedures in Java.
If you do not want to write stored procedures, as a living Java, I prefer to write in Java, with pl/sql need to memorize a lot of grammar (Pascal class syntax) and functions, far less than using JAVA/JDBC so familiar. Also, databases like DB2 support Java stored procedures, so it's no better to learn a way to write stored procedures for each type of data.
The Java stored procedures differ from the general JDBC programs:
1. Security restrictions, after all, are running within Oracle, not allowing access to operating system resources, such as files.
2. Get database join mode, connection = new Oracledriver (). DefaultConnection ();
3.system.out,system.err,system.in input and output are different. You can take advantage of some command redirection.
Here's an example of Hello world with a Java stored procedure.
1 in Plsqldeveloper, add a TESTJAVA1 class to Java source,
Code
create or replace and compile java source named TestJava1 as
public class TestJava1
{
public static void test()
{
System.out.println("Hello");
}
}
Execute it to save and compile.
2) Add a procedure and execute the following command:
Code
create or replace procedure testJava1
as
language java name 'TestJava1.test()';
3 Enter in command window
Code
SET SERVEROUTPUT ON;
CALL dbms_java.set_output(2000);
To redirect the System.out to the current window;
Enter in command window, exec testJava1 ();
You can see the result:
Hello
Pl/sql procedure successfully completed