-
Procedure java will not create a file until i disconnect
SORRY, THIS WAS NOT POSTED IN THE RIGHT FORUM
I have a procedure java that execute an export command on the oracle server. It works, but only when i disconnect from my sqlplus session. Why does the export will not work right away?
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Here is the code if you want to test it.
create user exp identified by exp;
grant connect to exp;
grant create procedure to exp;
grant create table to exp;
grant unlimited tablespace to exp;
connect exp/exp@10g.world
create or replace and compile java source named javacmdprompt as
import java.lang.*;
import java.util.*;
import java.util.Arrays;
import java.io.*;
public class javacmdprompt{
public static void cmdprompt(String directory) {
try {
Runtime.getRuntime().exec(directory,null);
}catch(IOException e){
System.out.println(e);
}
}
}
/
CREATE OR REPLACE Package My_pack as
Procedure proc_exec_cmd_java(p_commande in varchar2) as language java name 'javacmdprompt.cmdprompt( java.lang.String )';
End My_pack;
/
CREATE OR REPLACE Package body My_Pack as
Procedure proc_exec_cmd_java is
begin
null;
end proc_exec_cmd_java;
End My_Pack;
/
connect sys/logic10g@10g.world as sysdba
exec dbms_java.grant_permission( 'EXP','SYS:java.io.FilePermission', 'd:\oracle\product\10.2.0\db_1\BIN\exp', 'execute' )
exec dbms_java.grant_permission('EXP','java.io.FilePermission', '*', 'read, write');
exec dbms_java.grant_permission( 'EXP', 'SYS:java.lang.RuntimePermission','readFileDescriptor', '' );
exec dbms_java.grant_permission( 'EXP', 'SYS:java.lang.RuntimePermission','writeFileDescriptor', '' );
connect exp/exp@10g.world
create table My_table(no number);
execute My_pack.proc_exec_cmd_java('d:\oracle\product\10.2.0\db_1\BIN\exp userid=exp/exp file=d:\exp.dmp log=d:\exp.log consistent=y tables=(MY_TABLE)');
--
--IF I DISCONNECT I WILL SEE THE FILE D:\EXP.DMP
--
connect exp/exp@10g.world
Last edited by steeve123; 05-12-2006 at 09:58 AM.
-
I had the following responce from a colegue:
I had exactly the same problem trying to run exp in the background, but using JScript instead of java. The problem is that exp generates some output, and unless you collect that output, it will fill up its buffer and then block. When you disconnect, that closes the file handles, freeing up exp to continue running.
You might be able to get away with redirection ">exp.out 2>exp.err
Does anyone know how i can do this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|