如何使用java存储过程打开文件

发布于 2024-07-17 11:14:43 字数 103 浏览 3 评论 0原文

我使用的是oracle数据库10g。 我必须编写一个java stroed过程,通过它我可以调用服务器上的文件并将其存储在用户计算机本地。 我使用的是 Oracle Apex 3.1.1。

I am using oracle database 10g. I have to write a java stroed procedure through which i can call a file at the server and store it locally at the users machine. Im using oracle Apex 3.1.1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

星星的軌跡 2024-07-24 11:14:43

如果您谈论的是真正的 Oracle Java 存储过程,我认为您无法做到这一点。 请记住,Java 过程是在数据库中的 Oracle JVM 下运行的,这意味着它只能“看到”数据库主机文件系统。

If you're talking about a true Oracle Java stored procedure, I don't think you can do this. Remember that the Java procedure is running under the Oracle JVM in the database, which means that it can only "see" the database host filesystem.

诠释孤独 2024-07-24 11:14:43

有什么理由它必须是java吗? PL/SQL 中的 DBMS_FILE 通常应该可以正常工作。

否则,我认为(我已经很长时间没有做过java存储过程了)你应该能够像在java中那样打开一个IO流。

Any reason it has to be java? DBMS_FILE in PL/SQL should generally work fine.

Otherwise, I think ( I haven't done java stored procedures for a long time ) you should just be able to open an IO stream as you always would in java.

挖鼻大婶 2024-07-24 11:14:43

既然您使用的是 APEX 3.1,是否有理由可以通过 APEX(因此是 Web 服务器)简单地创建指向服务器上的文件的链接来下载文件?

您也可以通过 UTL_FILE 包来执行此操作,只是不要忘记首先运行 CREATE DIRECTORY 并在该目录上授予 READ 权限。

我认为您也可以通过 java 打开文件,但前提是您首先授予权限以允许 Oracle 进程访问系统上的目录。 这看起来确实是最复杂的方法。

Since you are using APEX 3.1, is there a reason why you can simply create a link to the file on the server through APEX (hence the Web Server) to download the file?

You can also do this through UTL_FILE package, just don't forget to run the CREATE DIRECTORY and grant READ on the directory first.

I think you can do the file open through java as well, but only if you do the grant first to allow the Oracle process access to the directories on your system. This does seem like the most complex method.

强辩 2024-07-24 11:14:43

为什么选择 Java 存储过程? 仅仅因为您认为 PL/SQL 无法完成?

PL/SQL 中有几个 FTP 实现。 Sourceforge 有一个。 Tim Hall 在 他的 Oracle- 上发表了一篇文章 -基本站点

1http://sourceforge.net/projects/plsqlftp/ "UTL_FTP 项目

Why a Java Stored Procedure? Just because you think it cannot be done in PL/SQL?

There are a couple of FTP implementations in PL/SQL. Sourceforge has one. Tim Hall has published one on his Oracle-Base site.

1: http://sourceforge.net/projects/plsqlftp/ "UTL_FTP project

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文