Oracle Database Java Developer's Guide, 10g Release 2 (10.2)

10g Release 2 (10.2)

B14187-01

Contents

List of Examples

List of Figures

List of Tables

Title and Copyright Information

Preface

- Intended Audience

- Documentation Accessibility

- Structure

- Related Documents

- Conventions

1 Introduction to Java in Oracle Database

- Overview of Java

- Java and Object-Oriented Programming Terminology

- Classes

- Objects

- Interfaces

- Encapsulation

- Inheritance

- Polymorphism

- Key Features of the Java Language

- The JVM

- Java Class Hierarchy

- Using Java in Oracle Database

- Java and RDBMS: A Robust Combination

- Multithreading

- Automated Storage Management With Garbage Collection

- Footprint

- Performance

- Dynamic Class Loading

- The Oracle JVM

- Process Area

- The main() Method

- The GUI

- The IDE

- Main Components of the Oracle JVM

- Library Manager

- Compiler

- Interpreter

- Class Loader

- Verifier

- Server-Side JDBC Internal Driver

- Server-Side SQLJ Translator

- Java Application Strategy of Oracle

- Java in Database Application Development

- Java Programming Environment

- Java Stored Procedures

- PL/SQL Integration and Oracle RDBMS Functionality

- JDBC Drivers

- SQLJ

- JPublisher

- Development Tools

- Desupport of J2EE Technologies in the Oracle Database

- Memory Model for Dedicated Mode Sessions

- What's New in this Release?

- Upgrading to J2SE 1.4.2

- Auditing SQL Statements Related to Java Schema Objects

- The PGA_AGGREGATE_TARGET parameter

2 Java Applications on Oracle Database

- Database Sessions Imposed on Java Applications

- Execution Control

- Java Code, Binaries, and Resources Storage

- Preparing Java Class Methods for Execution

- Compiling Java Classes

- Compiling Source Through javac

- Compiling Source Through loadjava

- Compiling Source at Run Time

- Specifying Compiler Options

- Recompiling Automatically

- Resolving Class Dependencies

- Loading Classes

- Granting Execute Rights

- Controlling the Current User

- Checking Java Uploads

- Publishing

- Auditing

- User Interfaces on the Server

- Shortened Class Names

- Class.forName() in Oracle Database

- Supply ClassLoader in Class.forName()

- Supply Class and Schema Names to classForNameAndSchema()

- Supply Class and Schema Names to lookupClass()

- Supply Class and Schema Names when Serializing

- Class.forName Example

- Managing Your Operating System Resources

- Overview of Operating System Resources

- Garbage Collection and Operating System Resources

- Threading in Oracle Database

- Shared Servers Considerations

- End-of-Call Migration

- Oracle-Specific Support for End-of-Call Optimization

- The EndOfCallRegistry.registerCallback() Method

- The EndOfCallRegistry.runCallbacks() Method

- The Callback Interface

- The Callback.act() method

- Operating System Resources Affected Across Calls

3 Calling Java Methods in Oracle Database

- Invoking Java Methods

- Utilizing Java Stored Procedures

- Utilizing JNI Support

- Utilizing SQLJ and JDBC for Querying the Database

- JDBC

- SQLJ

- Example Comparing JDBC and SQLJ

- Complete SQLJ Example

- SQLJ Strong Typing Paradigm

- Translating a SQLJ Program

- Running a SQLJ Program in the Server

- Converting a Client Application to Run on the Server

- Interacting with PL/SQL

- Debugging Server Applications

- How To Tell You Are Running on the Server

- Redirecting Output on the Server

- Support for Calling Java Stored Procedures Directly

- Using the Native Java Interface

4 Java Installation and Configuration

- Initializing a Java-Enabled Database

- Configuring with Oracle Database Template

- Modifying an Existing Oracle Database to Include Oracle JVM

- Configuring Oracle JVM

- Using The DBMS_JAVA Package

- Enabling the Java Client

- Install J2SE on the Client

- Set Up Environment Variables

- Test Install with Samples

5 Developing Java Stored Procedures

- Stored Procedures and Run-Time Contexts

- Functions and Procedures

- Database Triggers

- Object-Relational Methods

- Advantages of Stored Procedures

- Performance

- Productivity and Ease of Use

- Scalability

- Maintainability

- Interoperability

- Replication

- Security

- Java Stored Procedure Configuration

- Java Stored Procedures Steps

- Step 1: Create or Reuse the Java Classes

- Step 2: Load and Resolve the Java Classes

- Step 3: Publish the Java Classes

- Step 4: Call the Stored Procedures

- Step 5: Debug the Stored Procedures, if Necessary

6 Publishing Java Classes With Call Specifications

- Understanding Call Specifications

- Defining Call Specifications

- Setting Parameter Modes

- Mapping Data Types

- Using the Server-Side Internal JDBC Driver

- Writing Top-Level Call Specifications

- Writing Packaged Call Specifications

- Writing Object Type Call Specifications

- Declaring Attributes

- Declaring Methods

- Map and Order Methods

- Constructor Methods

- Examples

7 Calling Stored Procedures

- Calling Java from the Top Level

- Redirecting Output

- Examples of Calling Java Stored Procedures From the Top Level

- Calling Java from Database Triggers

- Calling Java from SQL DML

- Calling Java from PL/SQL

- Calling PL/SQL from Java

- How Oracle JVM Handles Exceptions

8 Java Stored Procedures Application Example

- Drawing the Entity-Relationship Diagram

- Planning the Database Schema

- Creating the Database Tables

- Writing the Java Classes

- Loading the Java Classes

- Publishing the Java Classes

- Calling the Java Stored Procedures

9 Oracle Database Java Application Performance

- Natively Compiled Code

- Accelerator Overview

- Oracle Database Core Java Class Libraries

- Natively Compiling Java Application Class Libraries

- Running the Accelerator

- The ncomp Tool

- Native Compilation Usage Scenarios

- The deploync Tool

- The statusnc Tool

- Java Memory Usage

- Configuring Memory Initialization Parameters

- Initializing Pool Sizes within Database Templates

- Java Pool Memory

- Displaying Used Amounts of Java Pool Memory

- Correcting Out of Memory Errors

10 Security for Oracle Database Java Applications

- Network Connection Security

- Database Contents and Oracle JVM Security

- Java2 Security

- Setting Permissions

- Fine-Grain Definition for Each Permission

- General Permission Definition Assigned to Roles

- Debugging Permissions

- Permission for Loading Classes

- Database Authentication Mechanisms

11 Schema Objects and Oracle JVM Utilities

- Schema Objects Overview

- What and When to Load

- Resolution

- Digest Table

- Compilation

- The loadjava Tool

- Syntax

- Argument Summary

- Argument Details

- The dropjava Tool

- Syntax

- Argument Summary

- Argument Details

- Dropping Resources

- The ojvmjava Tool

- Syntax

- Argument Summary

- Example

- Functionality

- ojvmjava Options

- Shell Commands

12 Database Web Services

- Overview of Database Web Services

- Using Oracle Database as Service Provider for Web Services

- How to Use JPublisher for Web Services Call-Ins

- Features of Oracle Database as a Web Service Provider

- JPublisher Support for Web Services Call-Ins to Oracle Database

- Using Oracle Database as Service Consumer for Web Services

- How to Use Oracle Database for Web Services Call-Outs

- Web Service Data Sources (Virtual Table Support)

- Features of Oracle Database as a Web Service Consumer

- JPublisher Generation Overview

- Adjusting the Mapping of SQL Types

A DBMS_JAVA Package

- longname

- shortname

- get_compiler_option

- set_compiler_option

- reset_compiler_option

- resolver

- derivedFrom

- fixed_in_instance

- set_output

- start_debugging

- stop_debugging

- restart_debugging

- export_source

- export_class

- export_resource

- loadjava

- dropjava

- grant_permission

- restrict_permission

- grant_policy_permission

- revoke_permission

- disable_permission

- enable_permission

- delete_permission

- set_preference

Index

List of Examples

- 2-1 Retrieve Resolver from Current Class

- 2-2 Retrieve Resolver from Calling Class

- 2-3 Providing Schema and Class Names

- 2-4 Closing Your Operating System Resources

- 2-5 Compromising Your Operating System Resources

- 2-6 Correctly Managing Your Operating System Resources

- 6-1 Publishing a Simple JDBC Stored Procedure

- 6-2 Publishing the main() Method

- 6-3 Publishing a Method That Returns an Integer Value

- 6-4 Publishing a Method That Switches the Values of Its Arguments

- 6-5 Packaged Call Specification

- 7-1 A Simple JDBC Stored Procedure

- 7-2 Fibonacci Sequence

- 7-3 Calling Java Stored Procedure from Database Trigger - I

- 7-4 Calling Java Stored Procedure from Database Trigger - II

- 10-1 Granting Permissions

- 10-2 Limiting Permissions

- 10-3 Granting PolicyTable Permission