Loadjava importing Java into the Oracle database

Source: Internet
Author: User
Tags oracle documentation

1) Load Jar file


Loadjava-r-f-verbose-resolve-user Xmlbook/xmlbook Xmlparserv2.jar



2) Load class file


Loadjava-r-f-user user_name/password[@URL] Oracle/aaa/bbb/ccc.class



3) Remove Java classes from the database


Dropjava-r-f-user user_name/password[@URL] [option_list] File_list



4) Call Java stored procedure


sql> variable myString varchar2[20];
Sql> call HelloWorld () into:mystring;
Call completed.
sql> print myString;
MYSTRING---------------------Hello World



5) Creating a PL/SQL Wrapper
The syntax for creating this procedure is:


CREATE [OR REPLACE] {
PROCEDURE procedure_name [(param[, param ...]) |
FUNCTION function_name [(param[, param ...])]
RETURN Plsql_type]}

[AUTHID {definer | Current_User}]
[Parallel_enable]
[Deterministic]
{is | as} LANGUAGE JAVA
NAME ' Java_method (java_type[, Java_type] ...)
[RETURN Java_type];


where param is defined as:


param: = parameter_name [In | Out | In out] Plsql_type



Some details is writen at
Http://www.databasejournal.com/books/print.php/10979_2106941_2

6) Use JDeveloper IDE to load Java class
Run->deploy->new Deploy Profile->general->deploy profiles->load java and Java stored procedure




-andresolve
Compiles source files and resolves each class file as it is loaded. This option and-resolve is mutually exclusive. If Neither is specified, files be loaded but not compiled or resolved. In general, this mode isn't recommended because it can leave classes that has unresolved references marked valid, Causin G an error at runtime.

-debug
Generates debug information. This option was equivalent to JAVAC-G.

-definer
Specifies that the methods of uploaded classes would execute with the privileges of their definer, not their invoker. (By default, methods execute with the privileges of their invoker.) Different Definers can has Different privileges, and an application can has many classes, so make sure the methods of a Given class execute only with the privileges they need.

Note that oracle8i Release 8.1.5 does is seem to conform to the Oracle documentation; The default seems to is to run with Definer rights.

-encoding
Sets (or resets) the-encoding option in the database table Java$options to the specified value, which must is the name of A standard JDK encoding scheme (the default is "Latin1"). The compiler uses this value, so the encoding of uploaded source files must match the specified encoding.

-force
Forces the loading of Java class files, whether or not they has been loaded before. By default, previously loaded class files is rejected. You cannot force the loading of a class file if you previously loaded the source file. You must drop the source schema object first.

-grant
Grants the EXECUTE privilege on uploaded classes to the listed users or roles. (To the methods of a class directly, the users must has the EXECUTE privilege.)

This option is cumulative. Users and roles is added to the list of those have the EXECUTE privilege.

To revoke the privilege, either drop and reload the schema object without specifying-grant, or use the SQL revoke Stateme Nt. To grant the privilege on a object in another user's schema, you must has the CREATE PROCEDURE with grant privilege.

-oci8
Directs Loadjava to communicate with the database using the OCI JDBC driver. This option (the default) And-thin is mutually exclusive.

-oracleresolver
Binds newly created class schema objects to the following predefined resolver spec:

"((* definer ' S_schema) (* public))"
-resolver is mutually exclusive.

-resolve
After all class files on the command line is loaded and compiled (if necessary), resolves all external references in thos E classes. If This option was not specified, files were loaded but not compiled or resolved until runtime.

Specify this option to compile (if necessary) and resolve a class that is loaded previously. You need isn't specify The-force option because resolution is do independently, after loading.

-resolver
Binds newly created class schema objects to a user-defined resolver spec. Because It contains spaces, the resolver spec must is enclosed by double quotes. This option And-oracleresolver (the default) is mutually exclusive.

-schema
Assigns newly created Java schema objects to the specified schema. If This option isn't specified, then the logon schema is used. You must has the CREATE any PROCEDURE privilege to load into another user ' s schema.

-synonym
Creates a public synonym for uploaded classes, making them accessible outside the schema into which they is loaded. To specify this option, you must has the CREATE public synonym privilege.

If you specify the This option for the source files, it also applies to classes compiled from those source files.

-thin
Directs Loadjava to communicate with the database using the thin JDBC driver. This option and-oci8 (the default) is mutually exclusive.

-verbose
Enables the verbose mode, in which progress messages is displayed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.