How do I create or replace a procedure in JDBC?
I created the procedure in oracle, but I cannot replace the procedure from Java.
I have the following, but it does not work:
Statement stmt0 = conn.createStatement();
String query0 =
"CREATE OR REPLACE PROCEDURE my_proc " +
//blah blah blah
//blah blah blah
//blah blah blah
"END; " +
". " +
"run; ";
stmt0.execute(query0);
From online tutorials, I see that i’m supposed to use something like:
cstmt = conn.prepareCall (SQL);
But I haven’t been able to make it work.
If you want to see more of my code, I will provide.
First of all, you can do this.
You want to prepare and execute from jdbc, to begin with.
Second, you need to cut off your last line with the “. ” and “run; ” which look like they are straight from SQL*Plus.
Note you have not put any newlines in your Java string, but that won’t matter. You seem to have added trailing spaces which is necessary.
I suggest logging or system.out.println of the string before you execute.
Don’t have a DBMS right now, but it should be something like