ORACLE - Oracle9i Java Stored Procedures Developers Guide (2002).pdf

(682 KB) Pobierz
Oracle9i Java Stored Procedures Developer’s Guide
Oracle9i
Java Stored Procedures Developer’s Guide
Release 2 (9.2)
March 2002
Part No. A96659-01
30297371.003.png 30297371.004.png
Oracle9 i Java Stored Procedures Developer’s Guide, Release 2 (9.2)
Part No. A96659-01
Copyright © 2000, 2002 Oracle Corporation. All rights reserved.
Author: Tom Portfolio
Graphics Artist: Valarie Moore
Contributors: Sheryl Maring, Dave Alpern, Gray Clossman, Matthieu Devin, Steve Harris, Hal
Hildebrand, Susan Kraft, Sunil Kunisetty, Thomas Kurian, Dave Rosenberg, Jerry Schwarz.
The Programs (which include both the software and documentation) contain proprietary information of
Oracle Corporation; they are provided under a license agreement containing restrictions on use and
disclosure and are also protected by copyright, patent and other intellectual and industrial property
laws. Reverse engineering, disassembly or decompilation of the Programs, except to the extent required
to obtain interoperability with other independently created software or as specified by law, is prohibited.
The information contained in this document is subject to change without notice. If you find any problems
in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this
document is error-free. Except as may be expressly permitted in your license agreement for these
Programs, no part of these Programs may be reproduced or transmitted in any form or by any means,
electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation.
If the Programs are delivered to the U.S. Government or anyone licensing or using the programs on
behalf of the U.S. Government, the following notice is applicable:
Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial
computer software" and use, duplication, and disclosure of the Programs, including documentation,
shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement.
Otherwise, Programs delivered subject to the Federal Acquisition Regulations are "restricted computer
software" and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR
52.227-19, Commercial Computer Software - Restricted Rights (June, 1987). Oracle Corporation, 500
Oracle Parkway, Redwood City, CA 94065.
The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently
dangerous applications. It shall be the licensee's responsibility to take all appropriate fail-safe, backup,
redundancy, and other measures to ensure the safe use of such applications if the Programs are used for
such purposes, and Oracle Corporation disclaims liability for any damages caused by such use of the
Programs.
Oracle is a registered trademark, and Oracle9 i , Oracle8 i , PL/SQL, Pro*C/C++ and SQL*Plus are
trademarks or registered trademarks of Oracle Corporation. Other names may be trademarks of their
respective owners.
30297371.005.png
Contents
Send Us Your Comments .................................................................................................................. vii
Preface ............................................................................................................................................................ ix
1 Introduction
Java and the RDBMS: A Robust Combination ............................................................................. 1-2
Stored Procedures and Run-Time Contexts ................................................................................... 1-3
Functions and Procedures ........................................................................................................... 1-4
Database Triggers ......................................................................................................................... 1-5
Object-Relational Methods .......................................................................................................... 1-6
Advantages of Stored Procedures .................................................................................................... 1-6
Performance................................................................................................................................... 1-6
Productivity and Ease of Use...................................................................................................... 1-7
Scalability....................................................................................................................................... 1-7
Maintainability.............................................................................................................................. 1-7
Interoperability ............................................................................................................................. 1-7
Replication ..................................................................................................................................... 1-8
Security........................................................................................................................................... 1-8
The Oracle JVM and Its Components ............................................................................................. 1-9
The Oracle JVM versus Client JVMs ........................................................................................ 1-10
Main Components of the Oracle JVM ..................................................................................... 1-11
Java Stored Procedure Configuration ............................................................................................ 1-16
Developing Stored Procedures: An Overview ............................................................................ 1-17
iii
30297371.006.png
2 Loading Java Classes
Java in the Database ........................................................................................................................... 2-2
Java Code, Binaries, and Resources Storage .................................................................................. 2-3
Preparing Java Class Methods for Execution ................................................................................ 2-4
Compiling Java Classes................................................................................................................ 2-4
Resolving Class Dependencies ................................................................................................... 2-9
Loading Classes........................................................................................................................... 2-12
How to Grant Execute Rights ................................................................................................... 2-15
Checking Java Uploads .............................................................................................................. 2-16
User Interfaces on the Server .......................................................................................................... 2-18
Shortened Class Names ................................................................................................................... 2-19
Controlling the Current User .......................................................................................................... 2-20
3 Publishing Java Classes
Understanding Call Specs ................................................................................................................. 3-2
Defining Call Specs: Basic Requirements ...................................................................................... 3-3
Setting Parameter Modes............................................................................................................. 3-3
Mapping Datatypes ...................................................................................................................... 3-4
Using the Server-Side Internal JDBC Driver............................................................................. 3-7
Using the Server-Side SQLJ Translator...................................................................................... 3-9
Writing Top-Level Call Specs ......................................................................................................... 3-11
Writing Packaged Call Specs .......................................................................................................... 3-15
Writing Object Type Call Specs ..................................................................................................... 3-18
Declaring Attributes ................................................................................................................... 3-19
Declaring Methods ..................................................................................................................... 3-19
4 Calling Stored Procedures
Calling Java from the Top Level ....................................................................................................... 4-2
Redirecting Output ....................................................................................................................... 4-2
Calling Java from Database Triggers ............................................................................................... 4-6
Calling Java from SQL DML .......................................................................................................... 4-10
Restrictions................................................................................................................................... 4-11
Calling Java from PL/SQL ............................................................................................................... 4-12
Calling PL/SQL from Java ............................................................................................................... 4-14
iv
30297371.001.png
How the JVM Handles Exceptions ................................................................................................ 4-15
5 Developing an Application
Drawing the Entity-Relationship Diagram ................................................................................... 5-2
Planning the Database Schema ........................................................................................................ 5-5
Creating the Database Tables ........................................................................................................... 5-7
Writing the Java Classes .................................................................................................................... 5-9
Loading the Java Classes ................................................................................................................. 5-15
Publishing the Java Classes ............................................................................................................ 5-16
Calling the Java Stored Procedures ............................................................................................... 5-18
Index
v
30297371.002.png
Zgłoś jeśli naruszono regulamin