15-15. Querying the Database to Help Resolve Java Compilation Issues

Problem

You are attempting to compile Java source within the database, and you are receiving an unsuccessful result. You need to determine the underlying issue to the problem that is preventing the Java source from compiling correctly.

Solution

Query the USER_ERRORS table to determine the cause of the compilation issue. For example, suppose the JavaUtils class source is loaded into the database with an incorrect variable name. This will cause a compiler error that will be displayed within the USER_ERRORS table. The following is an excerpt from a SQL*Plus session where an attempt has been made to compile the code:

SQL> ALTER JAVA SOURCE "JavaUtils" RESOLVE;

Warning: Java altered with compilation errors.

Since compilation errors have occurred, query the USER_ERRORS table to determine the exact cause of the error so that it can be repaired. The following query demonstrates this technique:

SQL> COL TEXT FOR A25
SQL> SELECT NAME, TYPE, LINE, TEXT
  2  FROM USER_ERRORS
  3  WHERE TYPE LIKE 'JAVA%';

NAME                   TYPE          LINE TEXT
------------------------------ ------------ ---------- -------------------------
JavaUtils               JAVA CLASS         0 ORA-29535: source require
                               s recompilation

JavaUtils               JAVA SOURCE         0 JavaUtils:51: cannot find
                            symbol

JavaUtils               JAVA SOURCE         0 symbol  : variable me
JavaUtils               JAVA SOURCE         0 location: class JavaUtils
JavaUtils               JAVA SOURCE         0               ResultSet
                            rs = me.getSchemas();

NAME                   TYPE          LINE TEXT
------------------------------ ------------ ---------- -------------------------
JavaUtils               JAVA SOURCE         0
                                 ^

JavaUtils               JAVA SOURCE         0 1 error

7 rows selected.

How It Works

The USER_ERRORS table contains the most recent errors generated by PL/SQL or Java code. It is the most useful way to determine the issues that are causing compilation errors when attempting to resolve Java source errors. Unlike PL/SQL, you are unable to issue the SHOW ERRORS command to display the most recent compiler errors. The Java compiler, as well as the PL/SQL compiler, writes output to the USER_ERRORS table, making it a beneficial tool when writing Java code for the database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.55.75