RE: Java external procedure help?

  • From: "Robert Freeman" <robertgfreeman@xxxxxxxxx>
  • To: "Christian Antognini" <Christian.Antognini@xxxxxxxxxxxx>
  • Date: Sun, 11 Jun 2006 22:00:04 -0600

Ok, I need more help. I can now get the procedure to execute from Oracle
without an error, but it's not creating the output file
(c:\java\myfile.txt). When I run the procedure from java directly, it does
create the output file, so the program itself is OK.

Any ideas?

Here is the Java:

import java.io.*;
class FileOutputDemo
{
        public static void main(String args[])
        {
                FileOutputStream out; // declare a file output object
                PrintStream p; // declare a print stream object
                try
                {
                        // Create a new file output stream
                        // connected to "myfile.txt"
                        out = new FileOutputStream("c:\\java\\myfile.txt");
                        // Connect print stream to the output stream
                        p = new PrintStream( out );
                        p.println ("This is written to a file");
                        p.close();
                }
                catch (Exception e)
                {
                        System.err.println ("Error writing to file");
                }
        }
}


-----Original Message-----
From: Christian Antognini [mailto:Christian.Antognini@xxxxxxxxxxxx]
Sent: Sunday, June 11, 2006 2:21 PM
To: robertgfreeman@xxxxxxxxx
Cc: oracle-l@xxxxxxxxxxxxx
Subject: RE: Java external procedure help?


Robert

>Create or replace procedure test_write
>is
>language java
>name 'FileOutputDemo(java.lang.String)';

You have to problems here:
- you reference the class instead of the method (main is not
"recognized"...)
- the parameter must be an array

Therefore the following should work:

Create or replace procedure test_write
is
language java
name 'FileOutputDemo.main(java.lang.String[])';


HTH
Chris

--
//www.freelists.org/webpage/oracle-l


Other related posts: