Home » Developer & Programmer » JDeveloper, Java & XML » Java, PL/SQL Proc (Oracle Database 10g Express Edition Release 10.2.0.1.0, UNIX)
Java, PL/SQL Proc [message #388653] Wed, 25 February 2009 20:44 Go to next message
wmgonzalbo
Messages: 98
Registered: November 2008
Member
Hi Experts:

Opted to post this in this java boards instead of pl/sql.. Hope i did the right thing.. Anyway i'm just clueless right now..

I was given this java class / java file:

> Myclass.class

- takes and input like this:

public class Myclass {
  public static void main(String[] args) {
  .
  .
  .
  }
}


- though it calls a package and other classes, and most likely these other classes are the ones returning a string output.

and i did these steps:


$ loadjava -user arbor Myclass.class
Password: password


SQL> EXECUTE DBMS_JAVA.GRANT_PERMISSION ('MYSHEMA', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' )

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_JAVA.GRANT_PERMISSION ('MYSHEMA', 'java.lang.RuntimePermission', '*', 'writeFileDescriptor' )

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_JAVA.GRANT_PERMISSION ('MYSHEMA', 'java.lang.RuntimePermission', '*', 'readFileDescriptor' )

PL/SQL procedure successfully completed.

-----

SQL> create or replace procedure Myclass_Proc (p_args IN VARCHAR2)
  2  AS LANGUAGE JAVA
  3  NAME 'Myclass(java.lang.String)';
  4  /

Warning: Procedure created with compilation errors.

SQL> sho err
Errors for PROCEDURE MYCLASS_PROC:

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      PL/SQL: Compilation unit analysis terminated
3/1      PLS-00311: the declaration of "Myclass(java.lang.String)"
         is incomplete or malformed

-----

-- i also did these:

SQL> create or replace function Myclass_Func (p_args IN VARCHAR2)
  2  RETURN VARCHAR2 AS LANGUAGE JAVA
  3  NAME 'Myclass(java.lang.String) return java.lang.String';
  4  /

Warning: Function created with compilation errors.

SQL> sho err
Errors for FUNCTION MYCLASS_FUNC:

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      PL/SQL: Compilation unit analysis terminated
3/1      PLS-00311: the declaration of "Myclass(java.lang.String) return java.lang.String"
         is incomplete or malformed


Dont know if my error is on java or pl/sql, but most likely its in my format.. im just clueless right now, if you could help or suggest something i would really appreciate it..


Regards,
Wilbert

[Updated on: Wed, 25 February 2009 20:52]

Report message to a moderator

Re: Java, PL/SQL Proc [message #388681 is a reply to message #388653] Wed, 25 February 2009 22:54 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Should be something like:
create or replace function Myclass_Func (p_args IN VARCHAR2)
RETURN VARCHAR2 AS LANGUAGE JAVA
NAME 'Myclass.Myfunction(java.lang.String) return java.lang.String';
/

Regards
Michel
Re: Java, PL/SQL Proc [message #388692 is a reply to message #388653] Wed, 25 February 2009 23:12 Go to previous messageGo to next message
wmgonzalbo
Messages: 98
Registered: November 2008
Member
Hi Michel C.,

Its seems there aren't any other function in the Myclass.class file.. just the main() and SEVERAL other import package.classes.. too bad i cant really post the java code itself in this thread, it would cause me alot of trouble..

even tried it this way:

SQL> create or replace function Myclass_Func (p_args IN VARCHAR2)
  2  RETURN VARCHAR2 AS LANGUAGE JAVA
  3  NAME 'Myclass.main(java.lang.String) return java.lang.String';
  4  /

Warning: Function created with compilation errors.

SQL> sho err
Errors for FUNCTION MYCLASS_FUNC:

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      PL/SQL: Compilation unit analysis terminated
3/1      PLS-00311: the declaration of "Myclass(java.lang.String) return java.lang.String"
         is incomplete or malformed


i'm still looking into this java Myclass.class file, if i was the one who created it, it would much easier to debug, oh well these scenarios cant be helped in this line of work...

Regards,
Wilbert
Re: Java, PL/SQL Proc [message #388727 is a reply to message #388692] Thu, 26 February 2009 00:40 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
"main" does not return a string. It is a procedure not a function from what you posted.

Quote:
bad i cant really post the java code itself in this thread,

Note: You can always post a test case that reproduces your issue.

Regards
Michel
Re: Java, PL/SQL Proc [message #388743 is a reply to message #388727] Thu, 26 February 2009 01:11 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
In addition, main does not have String as parameter, but String[]
Re: Java, PL/SQL Proc [message #388747 is a reply to message #388653] Thu, 26 February 2009 01:24 Go to previous message
wmgonzalbo
Messages: 98
Registered: November 2008
Member
Yup it doesnt return anything and I used String[].

Big thanks Michel C. and Frank!
Previous Topic: XML Parsing....need some info
Next Topic: [HELP] Error while validating XML against XSD using PL SQL
Goto Forum:
  


Current Time: Thu Mar 28 07:35:21 CDT 2024