views:

2416

answers:

1

I'm trying to load some java stored procedures into an Oracle 10g database through JDBC. The statement I'm executing is -

CREATE OR REPLACE JAVA SOURCE NAMED "test.Test" AS
package test;
public class Test {
    public static String myMethod(String a) {
     return a;
    }
};

Running this through TOAD works just fine, but when running through my JDBC client gives the following error -

Exception in thread "Thread-3" java.lang.NullPointerException
        at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:728)
        at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:478)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)
        at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1451)
        at ejsdal.CreateDBJavaSQL.executeScript(CreateDBJavaSQL.java:23)
        at ejsdal.OperationController.run(OperationController.java:182)

I'm using the java.sql.Statement's "executeUpdate" passing the string in the first code block.

It is possible to load java source through JDBC?

+3  A: 

Figured it out - need to set the

statement.setEscapeProcessing(false);

before executing the update. This is because the Java source file's { and } characters are misinterpreted as procedure call syntax by the JDBC driver.

Richard Nichols