The DDL statement to create the call spec will work fine; it won’t report any creation errors. When you attempt to execute the my_hello procedure, however, you receive an error message stating that there is no method named doIt in the class. The problem is that the method’s name is doit, not doIt (remember, case matters in Java!). To fix the problem, you must change the call spec to match the method name. Here’s the output from SQL*Plus:
SQL> SET SERVEROUTPUT ON SQL> EXEC DBMS_JAVA.SET_OUTPUT(1000); PL/SQL procedure successfully completed. SQL> CREATE OR REPLACE PROCEDURE my_hello 2 AS LANGUAGE JAVA 3 NAME 'helloWorld.doIt()'; 4 / Procedure created. SQL> EXEC my_hello java.lang.NoSuchMethodException: No applicable method found .. BEGIN my_hello; END; * ERROR at line 1: ORA-29531: no method doIt in class helloWorld ORA-06512: at "SCOTT.MY_HELLO", line 0 ORA-06512: at line 1
As in the previous exercise, the call spec compiles but doesn’t run. The problem in this case is that you can publish only static methods. To fix the problem, add the static keyword to the definition of doit, recompile, and reload the class.
The following query displays information about the Java objects in a user schema:
SELECT object_name, object_type, status, timestamp FROM user_objects WHERE (object_name NOT LIKE 'SYS_%' AND object_name NOT LIKE 'CREATE$%' AND object_name NOT LIKE 'JAVA$%' AND object_name NOT LIKE 'LOADLOB%') AND object_type LIKE 'JAVA %' ORDER BY object_type, object_name; ...