How to create a simple Java stored procedure

xiaoxiao2021-03-06  73

Software Environment:

1, operating system: Windows 2000 Server

2, Database: Oracle 8i R2 (8.1.7) for NT Enterprise Edition

3, installation path: c: / oracle

Implementation:

1. Create a file for Test.java

Public Class Test

{

Public static void main (string args [])

{

System.out.Println ("Hello this is a java procedure);

}

}

2, Javac Test.java

3, Java Test

4, SQL> CONN SYSTEM / Manager

SQL> Grant Create Any Directory TO Scott;

SQL> CONN Scott / Tiger

SQL> CREATE OR Replace Directory Test_dir as 'D: /';

The directory has been created.

SQL> CREATE OR Replace Java class using bfile (test_dir, 'test.class ")

2 /

Java has been created.

SQL> SELECT Object_name, Object_Type, Status from user_Objects;

SQL> Create or Replace Procedure Test_JAVA

As Language Java

Name 'Test.main (java.lang.string [])';

/

The process has been created.

SQL> SET ServerOutput on size 5000

SQL> Call dbms_java.set_output (5000);

The call is completed.

SQL> Execute Test_java;

Hello this is a java procedure

The PL / SQL process has been successfully completed.

SQL> Call test_java ();

Hello this is a java procedure

The call is completed.

转载请注明原文地址:https://www.9cbs.com/read-120794.html

New Post(0)