Main is a reserved function in Java you cannot use that in your
programs.
I just did this by changing the name to test. And it works.
HTH
Best Regards,
Ganesh R
Tel : +971 (4) 397 3337 Ext 420
Fax : +971 (4) 397 6262
HP : +971 (50) 745 6019
============================================
Live to learn... forget... and learn again.
============================================
-----Original Message-----
Rich
Sent: Tuesday, June 04, 2002 9:09 PM
To: Multiple recipients of list ORACLE-L
Hey all,
Trying to get into this new fangled "Java" thingy in 8.1.7.2.0 on HP/UX.
Simple OS exec test, mostly plagarized:
// qlp.java
import java.lang.Runtime;
import java.lang.Process;
import java.io.IOException;
import java.lang.InterruptedException;
public class qlp {
public static int main(String args) {
int retval = 0;
try {
String lpCommand;
lpCommand = "/usr/bin/lp " + args;
Process p = Runtime.getRuntime().exec(lpCommand);
try {
p.waitFor();
} catch (InterruptedException intexc) {
System.out.println("Interrupted Exception on waitFor: "
+ intexc.getMessage());
}
retval = p.exitValue();
} catch (IOException e) {
e.printStackTrace();
}
return (retval);
}
}
// End of Java code
I run javac to compile it, then loadjava the class file into the DB. I
can then create a PL/SQL procedure as a wrapper:
CREATE OR REPLACE PROCEDURE qlp_proc (file_and_parms IN VARCHAR2) AS
LANGUAGE JAVA
NAME 'qlp.main (java.lang.String[])';
/
And it works, but I need to test for success/fail. But if I try a
FUNCTION
wrapper:
CREATE OR REPLACE FUNCTION qlp_func (file_and_parms IN VARCHAR2) RETURN
NUMBER AS LANGUAGE JAVA
NAME 'qlp.main (java.lang.String[]) return int';
/
I get PLS-00311: the declaration of "qlp.main (java.lang.String[])
return int" is incomplete or malformed.
Two questions: 1) Every example I've seen of the wrapper excludes the
brackets from the java.lang.String parameter def, but I can't get a
compile
without it. Why? And 2) Anyone know what's wrong with my FUNCTION
def?
Desperately needing a good Java tutorial, too!
TIA!
Rich Jesse System/Database Administrator
[EMAIL PROTECTED] Quad/Tech International, Sussex, WI
USA
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Jesse, Rich
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the
message BODY, include a line containing: UNSUB ORACLE-L (or the name of
mailing list you want to be removed from). You may also send the HELP
command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Ganesh Raja
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).