1. Method 1: Use loadjava;
(1) Use the JDK provided by Oracle to compile the Java source file
D:/> C:/Oracle/product/10.1.0/db_1/JDK/bin/javac showdate. Java
Note: The machine may have a multi-version JDK environment, but you must use the JDK that comes with Oracle to compile files.
(2) Use loadjava to load the class
Loadjava-user myweb/myweb showdate. Class
After the code is loaded, the next step is similar to step 2 (2). Continue to create a function or process.
2. Method 2: Use the Java source directly in Oracle, and use the built-in JVM in Oracle.
Set serveroutput on
(1) create a Java source
Create or replace Java source named nowdate
As
Import java. util. date;
Public class showdate {
Public static date shownowdate (){
Return new date ();
}
}
/
(2) Release JAVA Source
Create or replace function fun_nowdate return varchar2
As
Language Java name 'showdate. shownowdate () return date ';
/
(3) test
Begin
Dbms_output.put_line (fun_nowdate );
End;
/
Appendix: Enabling oracle to support java stored procedures
1) set java_pool in init. ora and stop starting the database.
Java_pool_size = 96 m
2) images necessary to run initjavavm. SQL.
SQL> conn/as sysdba
SQL> @ $ ORACLE_HOME/javavm/install/initjvm. SQL
3) Check whether DB supports
Check whether dbms_java is created
SQL> select distinct owner, name from dba_source where lower (NAME) = 'dbms _ Java ';