Oracle8i SQL Reference
Release 2 (8.1.6)

A76989-01

Library

Product

Contents

Index

Prev Up Next

SQL Statements (continued), 11 of 20


CREATE JAVA

Syntax


invoker_rights_clause::=

Purpose

To create a schema object containing a Java source, class, or resource. For information on the following topics, see these books:

Prerequisites

To create or replace a schema object containing a Java source, class, or resource in your own schema, you must have CREATE PROCEDURE system privilege. To create such a schema object in another user's schema, you must have CREATE ANY PROCEDURE system privilege. To replace such a schema object in another user's schema, you must also have ALTER ANY PROCEDURE system privilege.

Keywords and Parameters

OR REPLACE 

re-creates the schema object containing the Java class, source, or resource if it already exists. Use this clause to change the definition of an existing object without dropping, re-creating, and regranting object privileges previously granted.

If you redefine a Java schema object and specify RESOLVE or COMPILE, Oracle recompiles or resolves the object. Whether or not the resolution or compilation is successful, Oracle invalidates classes that reference the Java schema object. For additional information, see "ALTER JAVA"

 

Users who had previously been granted privileges on a redefined function can still access the function without being regranted the privileges.  

RESOLVE | COMPILE 

are synonymous keywords. They specify that Oracle should attempt to resolve the Java schema object that is created if this statement succeeds.

  • When applied to a class, resolution of referenced names to other class schema objects occurs.

  • When applied to a source, source compilation occurs.

Restriction: You cannot specify this clause for a Java resource. 

NOFORCE 

rolls back the results of this CREATE command if you have specified either RESOLVE or COMPILE, and the resolution or compilation fails. If you do not specify this option, Oracle takes no action if the resolution or compilation fails (that is, the created schema object remains). 

JAVA SOURCE 

loads a Java source file.  

JAVA CLASS 

loads a Java class file. 

JAVA RESOURCE 

loads a Java resource file. 

NAMED  

is required for a Java source or resource. The primary_name must be enclosed in double quotation marks.

  • For a Java source, this clause specifies the name of the schema object in which the source code is held. A successful CREATE JAVA SOURCE statement will also create additional schema objects to hold each of the Java classes defined by the source.

  • For a Java resource, this clause specifies the name of the schema object to hold the Java resource.

  • Use double quotation marks to preserve lower- or mixed-case primary_name.

If you do not specify schema, Oracle creates the object in your own schema. 

 

Restrictions:

  • You cannot specify NAMED for a Java class.

  • The primary_name cannot contain a database link.

 

SCHEMA schema 

applies only to a Java class. This optional clause specifies the schema in which the object containing the Java file resides. If you do not specify schema and you do not specify NAMED (above), Oracle creates the object in your own schema. 

invoker_rights_clause 

specifies whether the methods of the class execute with the privileges and in the schema of the user who owns the class or with the privileges and in the schema of CURRENT_USER. For information on how CURRENT_USER is determined, see Oracle8i Concepts and Oracle8i Application Developer's Guide - Fundamentals.

This clause also determines how Oracle resolves external names in queries, DML operations, and dynamic SQL statements in the member functions and procedures of the type.

See Also: Oracle8i Java Stored Procedures Developer's Guide

 

AUTHID CURRENT_USER 

specifies that the methods of the class execute with the privileges of CURRENT_USER. This clause is the default and creates an "invoker-rights class."

This clause also specifies that external names in queries, DML operations, and dynamic SQL statements resolve in the schema of CURRENT_USER. External names in all other statements resolve in the schema in which the methods reside.  

 

AUTHID DEFINER 

specifies that the methods of the class execute with the privileges of the owner of the schema in which the class resides, and that external names resolve in the schema where the class resides. 

RESOLVER  

specifies a mapping of the fully qualified Java name to a Java schema object, where

  • match_string is either a fully qualified Java name, a wildcard that can match such a Java name, or a wildcard that can match any name.

  • schema_name designates a schema to be searched for the corresponding Java schema object.

  • A dash (-) as an alternative to schema_name indicates that if match_string matches a valid Java name, Oracle can leave the name unresolved. The resolution succeeds, but the name cannot be used at run time by the class.

This mapping is stored with the definition of the schema objects created in this command for use in later resolutions (either implicit or in explicit ALTER ... RESOLVE statements).  

USING 

determines a sequence of character (CLOB or BFILE) or binary (BLOB or BFILE) data for the Java class or resource. Oracle uses the sequence of characters to define one file for a Java class or resource, or one source file and one or more derived classes for a Java source. 

 

BFILE 

identifies a previously created file on the operating system (directory_object_name) and server file (server_file_name) containing the sequence. BFILE is usually interpreted as a character sequence by CREATE JAVA SOURCE and as a binary sequence by CREATE JAVA CLASS or CREATE JAVA RESOURCE.  

 

CLOB/BLOB/ BFILE subquery 

supplies a query that selects a single row and column of the type specified (CLOB, BLOB, or BFILE). The value of the column makes up the sequence of characters. 

 

key_for_BLOB 

supplies the following implicit query:

SELECT LOB FROM CREATE$JAVA$LOB$TABLE 
   WHERE NAME = 'key_for_BLOB';

Restriction: To use this case, the table CREATE$JAVA$LOB$TABLE must exist in the current schema and must have a column LOB of type BLOB and a column NAME of type VARCHAR2

AS source_text 

determines a sequence of characters for a Java or SQLJ source. 

Examples

Java Class Example

The following statement creates a schema object containing a Java class using the name found in a Java binary file:

CREATE JAVA CLASS USING BFILE (bfile_dir, 'Agent.class');

This example assumes the directory object bfile_dir, which points to the operating system directory containing the Java class Agent.class, already exists. In this example, the name of the class determines the name of the Java class schema object.

Java Source Example

The following statement creates a Java source schema object:

CREATE JAVA SOURCE NAMED "Hello" AS
   public class Hello {
      public static String hello() {
         return "Hello World";   } };
Java Resource Example

The following statement creates a Java resource schema object named APPTEXT from a BFILE:

CREATE JAVA RESOURCE NAMED "appText" 
   USING BFILE (bfile_dir, 'textBundle.dat');

Prev Up Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index