Notes for creating JAVA stored procedures in Oracle

Source: Internet
Author: User

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 ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.