简体   繁体   中英

Java in Oracle database

Is it any possibility to handle files (on client station) using Java.IO? I need to access files from user stations not from server.

I have found some codes like as following, but nothing deletes or creates.

Can you help me with this issue?

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "JDelete" AS
import java.io.File;
public class JDelete {
  public static int delete (String fileName) {
    File myFile = new File (fileName);
    boolean retval = myFile.delete();
    if (retval) return 1; else return 0;
  }
  public static void main (String args[]) {
    System.out.println (delete (args[0]) );
  }
}

create or replace function fDelete (file IN VARCHAR2)
RETURN NUMBER 
AS LANGUAGE JAVA
NAME 'JDelete.delete (java.lang.String) return int';

calling from sql

begin
  dbms_output.put_line(fDelete('C:\Rapoarte\u1.txt'));
end;

I wouldn't do it, but in case it's absolutely necessary you could define a network drive on the server, pointing to a directory on the client disk.. Then use the function to operate on that remote drive.

Consider that this solution will only be valid for one particular client machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM