
Oracle® Database Java Developer's Guide Release 18c E83762-01 February 2018 Oracle Database Java Developer's Guide, Release 18c E83762-01 Copyright © 1999, 2018, Oracle and/or its affiliates. All rights reserved. Primary Author: Tulika Das Contributors: Sheryl Maring, Rick Sapir, Michael Wiesenberg, Venkatasubramaniam Iyer, Brian Wright, Timothy Smith, Malik Kalfane Contributing Authors: Tanmay Choudhury , Kuassi Mensah, Mark Jungerman, Suresh Srinivasan, Ernest Tucker, Robert H Lee, Dmitry Nizhegorodov, Nataraju Neeluru, David Unietis, Paul Lo, Steve Harris, Ellen Barnes, Peter Benson, Greg Colvin, Bill Courington, Matthieu Devin, Jim Haungs, Hal Hildebrand, Susan Kraft, Thomas Kurian, Scott Meyer, Tom Portfolio, Dave Rosenberg, Jerry Schwarz, Harlan Sexton, Xuhua Li This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency- specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government. This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle. Contents Preface Audience xv Documentation Accessibility xv Related Documents xv Conventions xvi Changes in This Release for Oracle Database Java Developer's Guide Changes in Oracle Database 18c xvii 1 Introduction to Java in Oracle Database 1.1 Overview of Java 1-1 1.1.1 Java and Object-Oriented Programming Terminology 1-1 1.1.1.1 Classes 1-2 1.1.1.2 Objects 1-2 1.1.1.3 Inheritance 1-3 1.1.1.4 Interfaces 1-3 1.1.1.5 Encapsulation 1-4 1.1.1.6 Polymorphism 1-4 1.1.2 Key Features of the Java Language 1-5 1.1.3 Java Virtual Machine 1-6 1.1.4 Java Class Hierarchy 1-8 1.2 About Using Java in Oracle Database 1-9 1.2.1 Java and RDBMS: A Robust Combination 1-9 1.2.2 About Multithreading 1-10 1.2.3 Memory Spaces Management 1-11 1.2.4 Footprint 1-12 1.2.5 Performance of an Oracle JVM 1-13 1.2.6 Dynamic Class Loading 1-15 1.3 Overview of Oracle JVM 1-15 1.3.1 Process Area 1-16 iii 1.3.2 Java session initialization, duration and entrypoints 1-16 1.3.3 The GUI 1-17 1.3.4 The IDE 1-17 1.4 Feature List of Oracle JVM 1-17 1.5 Main Components of Oracle JVM 1-18 1.5.1 Library Manager 1-19 1.5.2 Compiler 1-19 1.5.3 Interpreter 1-20 1.5.4 Class Loader 1-20 1.5.5 Verifier 1-20 1.5.6 Server-Side JDBC Internal Driver 1-20 1.5.7 Server-Side SQLJ Translator 1-21 1.5.8 System Classes 1-21 1.6 Java Programming in Oracle Database 1-21 1.6.1 Java in Database Application Development 1-21 1.6.2 Java Programming Environment Usage 1-22 1.6.3 Java Stored Procedures 1-22 1.6.4 PL/SQL Integration and Oracle RDBMS Functionality 1-23 1.6.4.1 JDBC Drivers 1-23 1.6.4.2 SQLJ 1-24 1.6.5 Development Tools 1-24 1.6.6 Internet Protocol Version 6 Support 1-24 1.7 Support for Java 8 1-25 1.8 Memory Model for Dedicated Mode Sessions 1-25 2 Java Applications on Oracle Database 2.1 Database Sessions Imposed on Java Applications 2-1 2.2 Execution Control of Java Applications 2-3 2.3 Java Code, Binaries, and Resources Storage 2-3 2.4 About Java Classes Loaded in the Database 2-4 2.5 Preparing Java Class Methods for Execution 2-5 2.5.1 Compiling Java Classes 2-6 2.5.1.1 Compiling Source Through javac 2-7 2.5.1.2 Compiling Source Through the loadjava Tool 2-7 2.5.1.3 Compiling Source at Run Time 2-7 2.5.1.4 Specifying Compiler Options 2-7 2.5.1.5 Recompiling Source Programs Automatically 2-9 2.5.2 Overview of Resolving Class Dependencies 2-10 2.5.2.1 Allowing References to Nonexistent Classes 2-11 2.5.2.2 Bytecode Verifier 2-12 iv 2.5.3 Logging in Oracle JVM 2-13 2.5.4 Overview of Loading Classes Using the loadjava Tool 2-15 2.5.4.1 About Sharing of Metadata for User Classloaded Classes 2-17 2.5.4.2 Defining the Same Class Twice 2-17 2.5.4.3 About Designating Database Privileges and JVM Permissions 2-18 2.5.4.4 About Loading JAR or ZIP Files 2-18 2.5.4.5 Database Resident JARs 2-18 2.5.5 Overview of Granting Execute Rights 2-19 2.5.6 Overview of Controlling the Current User 2-20 2.5.7 Overview of Checking Java Uploads 2-22 2.5.8 About Publishing Java Methods Loaded in the Database 2-23 2.5.9 Overview of Auditing Java Classes Loaded in the Database 2-23 2.6 User Interfaces on the Server 2-25 2.7 Shortened Class Names 2-26 2.8 Class.forName() in Oracle Database 2-26 2.8.1 Supply ClassLoader in Class.forName() 2-27 2.8.2 Supply Class and Schema Names to classForNameAndSchema() 2-28 2.8.3 Supply Class and Schema Names to lookupClass() 2-29 2.8.4 Supply Class and Schema Names when Serializing 2-29 2.8.5 Class.forName Example 2-29 2.9 About Managing Your Operating System Resources 2-30 2.9.1 Overview of Operating System Resources 2-31 2.9.2 Garbage Collection and Operating System Resources 2-31 2.10 About Using the Runtime.exec Functionality in Oracle Database 2-33 2.11 Managing Your Applications Using JMX 2-33 2.11.1 Overview of JMX 2-33 2.11.2 Enabling and Starting JMX in a Session 2-34 2.11.3 Setting Oracle JVM JMX Defaults and Configurability 2-35 2.11.4 Examples of SQL calls to dbms_java.start_jmx_agent 2-36 2.11.5 Using JConsole to Monitor and Control Oracle JVM 2-37 2.11.5.1 Using the jconsole Command 2-37 2.11.5.2 About Using the JConsole interface 2-38 2.11.5.3 About Viewing Oracle JVM Summary Information 2-38 2.11.5.4 About Monitoring Memory Consumption 2-40 2.11.5.5 About Monitoring Thread Use 2-42 2.11.5.6 About Monitoring Class Loading 2-42 2.11.5.7 About Monitoring and Managing MBeans 2-43 2.11.5.8 About Viewing VM Information 2-46 2.11.5.9 The OracleRuntime MBean 2-47 2.11.5.10 Memory Thresholds 2-50 2.11.6 Important Security Notes 2-52 v 2.11.7 Shared Server Limitations for JMX 2-52 2.12 Overview of Threading in Oracle Database 2-53 2.12.1 Thread Life Cycle 2-54 2.12.2 System.exit(), OracleRuntime.exitSession(), and OracleRuntime.exitCall() 2-55 2.13 Shared Servers Considerations 2-56 2.13.1 End-of-Call Migration 2-56 2.13.2 Oracle-Specific Support for End-of-Call Optimization 2-57 2.13.3 The EndOfCallRegistry.registerCallback() Method 2-60 2.13.4 The EndOfCallRegistry.runCallbacks() Method 2-60 2.13.5 The Callback Interface 2-61 2.13.6 The Callback.act() method 2-61 2.13.7 Operating System Resources Affected Across Calls 2-61 3 Calling Java Methods in Oracle Database 3.1 Invoking Java Methods 3-1 3.1.1 Using PL/SQL Wrappers 3-1 3.1.2 About JNI Support 3-3 3.1.3 About Utilizing SQLJ and JDBC with Java in the Database 3-3 3.1.3.1 Using JDBC 3-4 3.1.3.2 Using SQLJ 3-4 3.1.3.3 Example Comparing JDBC and SQLJ 3-6 3.1.3.4 SQLJ Strong Typing Paradigm 3-7 3.1.3.5 Translating a SQLJ Program 3-8 3.1.3.6 Interaction with PL/SQL 3-8 3.1.4 About Using the
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages311 Page
-
File Size-