Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Java Stored Procedure

Re: Java Stored Procedure

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 23 Jul 2001 07:38:15 -0700
Message-ID: <9jhcsn023k0@drn.newsguy.com>

In article <9jhbi5$h7p$1_at_mosquito.HL.Siemens.DE>, "Suko says...
>
>Hi !
>
>I am trying to write to a file with a Java Stored Procedure, and its still
>not working ...... i don´t know wy??? ( i´m trying now quite for a while
>... )
>I have SUSE 7.1, Oracle 8.1.6 ...
>
>The Java Class works fine, when executing it from the Command line ... but
>after loading it in the database, the procedure executed without errors, but
>nothing is in the file.
>I am writing into /tmp so every user should have access to this directory.
>
>I have set the permission ( write, read, execute ) File ...
>i have also set the utl_file_dir = '*'
>
>can someone help ... need it very urgent
>
>thanks
>HP
>
>Code:
>import java.io.*;
>import java.util.Date;
>
>
>class starter
>{
> public static void main(String args []) throws IOException
> {
>
>
> try
> {
> PrintWriter log = new PrintWriter(new
> FileWriter("/tmp/starter.txt",true));
> log.println("JavaWriter: " + new Date().toString());
>
> log.flush();
> log.close();
> }
> catch ( Exception e)
> {
> System.err.println("Exc raised " + e);
> }
>
> }
>
>}
>
>

System.*.println stuff will goto the trace file on the server, alternatively, you can:

SQL> set serveroutput on
SQL> exec dbms_java.setoutput(100000)
SQL> exec your java procedure

and the System.* stuff will be displayed on screen. You are hitting an exception of some sort. Remember the Java stored proc will run as the Database user account in the OS so, if you ran this from the command line as "you", you might already have a /tmp/starter.txt that is owned by "you" and not "oracle" and "oracle" cannot open it for write (file permission problem)

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Mon Jul 23 2001 - 09:38:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US