12c中匯入java的jar檔案
1、建立表空間
[oracle@host01 /]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 21 15:29:33 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter session set container=xfpdb;
SQL> create tablespace xftbs datafile '/u01/app/oracle/oradata/PRODCDB/xfpdb/xftbs01.dbf' size 10m;
Tablespace created.
2、建立使用者並授權
SQL> create user xf identified by xf default tablespace xftbs quota unlimited on xftbs;
User created.
SQL> grant connect ,resource to xf;
Grant succeeded.
3、使用xf使用者連線資料庫執行jar包匯入
需要將commons-math3-3.0.jar檔案上傳至/home/oracle/files/下
使用dbms_java.loadjava匯入jar包
[oracle@host01 admin]$ sqlplus xf/xf@192.168.56.101:1521/xfpdb.example.com
SQL*Plus: Release 12.1.0.2.0 Production on Tue Dec 19 13:58:13 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> call dbms_java.loadjava('-v -r PUBLIC -sysnonym /home/oracle/files/commons-math3-3.0.jar');
Call completed.
SQL> begin
dbms_java.loadjava('-v -r PUBLIC -sysnonym /home/oracle/files/commons-math3-3.0.jar');
end;
/
PL/SQL procedure successfully completed.
SQL> exec dbms_java.loadjava('-v -r PUBLIC -sysnonym /home/oracle/files/commons-math3-3.0.jar');
PL/SQL procedure successfully completed.
或者使用loadjava命令
[oracle@host01 admin]$ loadjava -force -thin -user xf/xf@192.168.56.101:1521/xfpdb.example.com -resolve /home/oracle/files/commons-math3-3.0.jar
4、在Oracle資料庫建立java程式碼
SQL> create or replace and compile java source named jar_norm as
2 import org.apache.commons.math3.distribution.NormalDistribution;
3 public class jar_norm {
4 public static double s_inv(double s){
5 NormalDistribution normalDistribution =new NormalDistribution(0,1);
6 double S1=normalDistribution.inverseCumulativeProbability(s);
7 return S1;
8 }
9 public static double s_dist_c(double s){
10 NormalDistribution normalDistribution =new NormalDistribution(0,1);
11 double S1=normalDistribution.cumulativeProbability(s);
12 return S1;
13 }
14 }
15 /
Java created.
-end-
[oracle@host01 /]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 21 15:29:33 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter session set container=xfpdb;
SQL> create tablespace xftbs datafile '/u01/app/oracle/oradata/PRODCDB/xfpdb/xftbs01.dbf' size 10m;
Tablespace created.
2、建立使用者並授權
SQL> create user xf identified by xf default tablespace xftbs quota unlimited on xftbs;
User created.
SQL> grant connect ,resource to xf;
Grant succeeded.
3、使用xf使用者連線資料庫執行jar包匯入
需要將commons-math3-3.0.jar檔案上傳至/home/oracle/files/下
使用dbms_java.loadjava匯入jar包
[oracle@host01 admin]$ sqlplus xf/xf@192.168.56.101:1521/xfpdb.example.com
SQL*Plus: Release 12.1.0.2.0 Production on Tue Dec 19 13:58:13 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> call dbms_java.loadjava('-v -r PUBLIC -sysnonym /home/oracle/files/commons-math3-3.0.jar');
Call completed.
SQL> begin
dbms_java.loadjava('-v -r PUBLIC -sysnonym /home/oracle/files/commons-math3-3.0.jar');
end;
/
PL/SQL procedure successfully completed.
SQL> exec dbms_java.loadjava('-v -r PUBLIC -sysnonym /home/oracle/files/commons-math3-3.0.jar');
PL/SQL procedure successfully completed.
或者使用loadjava命令
[oracle@host01 admin]$ loadjava -force -thin -user xf/xf@192.168.56.101:1521/xfpdb.example.com -resolve /home/oracle/files/commons-math3-3.0.jar
4、在Oracle資料庫建立java程式碼
SQL> create or replace and compile java source named jar_norm as
2 import org.apache.commons.math3.distribution.NormalDistribution;
3 public class jar_norm {
4 public static double s_inv(double s){
5 NormalDistribution normalDistribution =new NormalDistribution(0,1);
6 double S1=normalDistribution.inverseCumulativeProbability(s);
7 return S1;
8 }
9 public static double s_dist_c(double s){
10 NormalDistribution normalDistribution =new NormalDistribution(0,1);
11 double S1=normalDistribution.cumulativeProbability(s);
12 return S1;
13 }
14 }
15 /
Java created.
-end-
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28373936/viewspace-2149028/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- java中的JAR檔案淺析JavaJAR
- Java POI匯入Excel檔案JavaExcel
- 向mysql中匯入.sql檔案MySql
- k8s Java 專案替換 jar 中的 class 檔案K8SJavaJAR
- IDEA 匯入 ***.jar包IdeaJAR
- IDEA匯入jar包IdeaJAR
- .sql檔案匯入到sql server中SQLServer
- 匯入excel檔案Excel
- Python-檔案的匯入Python
- NC65如何匯出補丁(jar檔案)JAR
- EasyExcel完成excel檔案的匯入匯出Excel
- Java中獲取JAR檔案中資源路徑的三種方法JavaJAR
- Springboot 獲取jar包中的檔案Spring BootJAR
- (十一)Electron 匯入匯出檔案
- maven 工程匯入jar包MavenJAR
- java怎麼匯入專案?java已有專案如何匯入eclipse?JavaEclipse
- Mysql匯入本地檔案MySql
- easyExcel分批匯入檔案Excel
- EEGlab匯入.mat檔案
- Mysql匯入csv檔案MySql
- navicat匯入sql檔案SQL
- java匯出CSV檔案Java
- java匯出Excel檔案JavaExcel
- IDEA 匯出和匯入jar包教程IdeaJAR
- java程式碼實現excel檔案資料匯入JavaExcel
- Angular 專案中匯入 styles 檔案到 Component 中的一些技巧Angular
- 【node】如何在ES modules中匯入JSON檔案JSON
- 關於java中Excel的匯入匯出JavaExcel
- 匯入jar包,main函式JARAI函式
- 建立HDFS,匯入HADOOP jar包HadoopJAR
- 將 crt 檔案匯入到 jks 檔案 -cg
- IDEA中Maven顯示存在依賴但專案中並未匯入依賴JARIdeaMavenJAR
- js 匯入json配置檔案JSON
- SQLServer匯入大CSV檔案SQLServer
- layui 表格操作匯入檔案UI
- java模板匯出PDF檔案Java
- Navicat如何匯入和匯出sql檔案SQL
- [Docker核心之容器、資料庫檔案的匯入匯出、容器映象的匯入匯出]Docker資料庫
- Java 匯入資料到Excel並提供檔案下載介面JavaExcel