Reputation: 35
I'm trying to call a PL/SQL stored procedure in Java. It works in SQL Developer. When I start the application nothing happens and I don't get any error messages. There are no changes in the database.
Here is the code:
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:orcl","student","student");
CallableStatement callProc = con.prepareCall("CALL compare_images(1,2)");
callProc.execute();
con.close();
}catch(Exception e) {
System.out.println(e);
}
Upvotes: 0
Views: 873
Reputation: 30865
As it it mentioned in specification of Connection interface. Method prepareCall(String)
first parameter is statement:
Typically this statement is specified using JDBC call escape syntax.
The escape syntax for JDBC look like {extension}
(more).
Upvotes: 0
Reputation:
That should be:
CallableStatement callProc = con.prepareCall("{call compare_images(1,2)}");
(note the curly braces enclosing the actual SQL statement)
Upvotes: 1