Reputation: 2785
Im calling a stored function like the following:
PreparedStatement deleteAll=connection.prepareStatement("{ call delete_all_data() }");
deleteAll.execute();
And in the logs i see:
15:16:31,950 WARN SqlExceptionHelper:143 - SQL Error: 0, SQLState: 42601
15:16:31,950 ERROR SqlExceptionHelper:144 - ERROR: syntax error at or near "{"
Position: 1
what is wrong with the prepareStatement??
Upvotes: 0
Views: 454
Reputation: 429
I use prepareCall to call stored procedures.
String SQL = "{call delete_all_data()}";
cstmt = conn.prepareCall (SQL);
Upvotes: 2
Reputation: 1499770
Change connection.prepareStatement
(which expects SQL) to connection.prepareCall
. That may very well be the only change you need, as a CallableStatement
is a PreparedStatement
.
Upvotes: 2