在 Oracle 中为 Java 存储过程设置类路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/529471/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 17:46:51  来源:igfitidea点击:

Setting classpath for a Java stored procedure in Oracle

javaoraclestored-procedures

提问by Chris Farmer

I've got an Oracle 10g database, and I have a third-party jar file. I want to be able to run a SQL select query in my database that ultimately runs code in my third-party library to retrieve info for inclusion in a SQL result set. I see lots of tutorials on "Java stored procedures" and these seem to be a promising way to do this, but none seem to use third-party libraries, and I can't seem to figure out how to specify a classpath for my jar file that will be recognized when I am running in Oracle. How can I do this?

我有一个 Oracle 10g 数据库,我有一个第三方 jar 文件。我希望能够在我的数据库中运行 SQL 选择查询,该查询最终在我的第三方库中运行代码以检索包含在 SQL 结果集中的信息。我看到很多关于“Java 存储过程”的教程,这些似乎是一种很有前途的方法,但似乎没有一个使用第三方库,而且我似乎无法弄清楚如何为我的 jar 指定类路径当我在 Oracle 中运行时将被识别的文件。我怎样才能做到这一点?

回答by Edwin

You can load the JAR file into the database using the loadjava tool. This tool accepts also .class, .java, .properties, .sqlj, .ser, .jar, or .zip files.

您可以使用 loadjava 工具将 JAR 文件加载到数据库中。此工具还接受 .class、.java、.properties、.sqlj、.ser、.jar 或 .zip 文件。

See the manual ( http://docs.oracle.com/cd/B19306_01/java.102/b14187/cheleven.htm#CACFHDJE) for more information.

有关更多信息,请参阅手册 ( http://docs.oracle.com/cd/B19306_01/java.102/b14187/cheleven.htm#CACFHDJE)。

回答by Joshua

Try adding the jar to the Windows/Unix CLASSPATH system variable.

尝试将 jar 添加到 Windows/Unix CLASSPATH 系统变量中。