loadjava 把java导入Oracle数据库

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存储过程 


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 are 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 are mutually exclusive. If neither is specified, files are loaded but not compiled or resolved. In general, this mode is not recommended because it can leave classes that have unresolved references marked valid, causing an error at runtime. 

-debug 
Generates debug information. This option is equivalent to javac -g. 

-definer 
Specifies that the methods of uploaded classes will execute with the privileges of their definer, not their invoker. (By default, methods execute with the privileges of their invoker.) Different definers can have different privileges, and an application can have 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 not seem to conform to the Oracle documentation; the default seems to be to run with definer rights. 

-encoding 
Sets (or resets) the -encoding option in the database table JAVA$OPTIONS to the specified value, which must be 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 have been loaded before. By default, previously loaded class files are 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 call the methods of a class directly, users must have the EXECUTE privilege.) 

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

To revoke the privilege, either drop and reload the schema object without specifying -grant, or use the SQL REVOKE statement. To grant the privilege on an object in another user's schema, you must have 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 are mutually exclusive. 

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

"((* definer's_schema) (* public))" 
-resolver are mutually exclusive. 

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

Specify this option to compile (if necessary) and resolve a class that was loaded previously. You need not specify the -force option because resolution is done independently, after loading. 

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

-schema 
Assigns newly created Java schema objects to the specified schema. If this option is not specified, then the logon schema is used. You must have 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 are loaded. To specify this option, you must have the CREATE PUBLIC SYNONYM privilege. 

If you specify this option for 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) are mutually exclusive. 

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

原文地址:https://www.cnblogs.com/zhangygl/p/3767179.html