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

时间:2022-04-13 05:14:29

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.

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

4 个解决方案

#1


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.

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

#2


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

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

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.

否则,我认为(我很长时间没有完成java存储过程)你应该像在java中一样打开IO流。

#3


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?

由于您使用的是APEX 3.1,有没有理由可以通过APEX(因此Web服务器)在服务器上创建文件链接来下载文件?

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.

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

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.

我认为您也可以通过java打开文件,但前提是您首先执行授权以允许Oracle进程访问系统上的目录。这似乎是最复杂的方法。

#4


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

为什么要使用Java存储过程?只是因为你认为它不能在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.

PL / SQL中有几个FTP实现。 Sourceforge有一个。 Tim Hall在他的Oracle-Base网站上发布了一个。

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

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

#1


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.

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

#2


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

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

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.

否则,我认为(我很长时间没有完成java存储过程)你应该像在java中一样打开IO流。

#3


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?

由于您使用的是APEX 3.1,有没有理由可以通过APEX(因此Web服务器)在服务器上创建文件链接来下载文件?

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.

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

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.

我认为您也可以通过java打开文件,但前提是您首先执行授权以允许Oracle进程访问系统上的目录。这似乎是最复杂的方法。

#4


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

为什么要使用Java存储过程?只是因为你认为它不能在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.

PL / SQL中有几个FTP实现。 Sourceforge有一个。 Tim Hall在他的Oracle-Base网站上发布了一个。

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

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