Java Mailing List Archive

http://www.dba.5341.com/

Home » Home (12/2007) » oracle l »

RE: Java external procedure help?

Robert Freeman

2006-06-12

Replies:

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@(protected)]
Sent: Sunday, June 11, 2006 2:21 PM
To: robertgfreeman@(protected)
Cc: oracle-l@(protected)
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

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


©2008 dba.5341.com - Jax Systems, LLC, U.S.A.