10

I have loaded a Java class into Oracle using the loadjava utility.

This class has some system.out.println messages.

When I execute a method from this class I want to see the the sysout messages.

Where can I find these messages?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
prabhakar
  • 101
  • 1
  • 1
  • 3

2 Answers2

7

System.out and System.err writes to the current trace files.

You can enable output to SQL*Plus or similar with

set serveroutput on size 10000

exec dbms_java.set_output(10000)

See the Java Developer's Guide here.

That said, you should ask yourself, what do I want to log, that my client would not like to see returned in the interface to my procedure?. The answer to that is usually nothing.

I have been able to set up http://www.slf4j.org/ with a JDBC database appender (I am unsure of the specifics).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
oluies
  • 17,694
  • 14
  • 74
  • 117
  • shouldn't your last statement be reversed? Log4jdbc is used to log via slf4j database activity to your local log files. You can use slf4j + logback for [logging to a database table](http://logback.qos.ch/manual/appenders.html#DBAppender) – darioo Nov 24 '10 at 14:26
  • yes, I am unsure of the specifics , it might have been log4j when I think about it. – oluies Nov 24 '10 at 14:43
6

An Oracle article provides some useful information.

Quote:

Your class:

public class SimpleJava {
   public void main(String[] args) {
      System.out.println("Here we are");
    }
}

Now, compile and load your class:

C:\oracle9i\bin>javac SimpleJava.java
C:\oracle9i\bin>loadjava -user scott/tiger SimpleJava.class

From SQL*Plus, create the PL/SQL wrapper to invoke the newly loaded Java class:

SQL> create or replace procedure call_simplejava
  2  as language java
  3  name 'SimpleJava.showMessage()';
  4  /

Execute the code from SQL*Plus:

SQL> set serveroutput on;
SQL> call dbms_java.set_output(50);

Call completed.

SQL> execute call_simplejava;
Here we are
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
darioo
  • 46,442
  • 10
  • 75
  • 103
  • The url does not work anymore link form the archive -https://web.archive.org/web/20070830154541/http://www.oracleutilities.com/OSUtil/loadjava.html – Anuswadh Apr 27 '20 at 13:46