通过Java代码调用Oracle存储过程时出错

时间:2015-09-16 03:36:19

标签: java oracle stored-procedures jdbc callable-statement

我在Java应用程序中调用PL / SQL过程来更新数据库条目。

Connection connection = null;
CallableStatement preparedCall = null;
Integer result = 0;
preparedCall = connection.prepareCall("{ call ? := pkg_temp.update_data(?, ?)}");
preparedCall.registerOutParameter(1, OracleTypes.INTEGER);
preparedCall.setString(2, variable1);
preparedCall.setString(3, cariable2);
result = preparedCall.executeUpdate();

但我在executeUpdate()

中收到以下错误
Caused by: java.sql.SQLException: ORA-06550: line 1, column 11:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
:= . ( @ % ; indicator
ORA-06550: line 1, column 51:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( ) , * % & - + / at mod remainder rem <an exponent (**)>
and or || multiset

我在哪里做错了?

1 个答案:

答案 0 :(得分:0)

:=错误,返回参数的占位符必须在 call关键字(as documented in the JavaDocs)之前列出

connection.prepareCall("{?= call pkg_temp.update_data(?, ?)}");