0

我在 WSO2 DSS 中执行以下 SQL 更新语句

Update Door
Set dcr_messageBox = :msg, dcr_servicesArea = :servArea
Where dcr_regNo = :regNo

我将此查询公开为休息服务。我不断收到以下错误

Current Request Name: _putdoorproperty
Current Params: {servArea=21, regNo=313, msg=21}
Nested Exception:-
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near ':'.

</soapenv:Text></soapenv:Reason><soapenv:Detail><axis2ns646:DataServiceFault xmlns:axis2ns646="http://ws.wso2.org/dataservice"><axis2ns646:current_params>{servArea=, regNo=3123, msg=}</axis2ns646:current_params><axis2ns646:current_request_name>_putdoctorproperty</axis2ns646:current_request_name><axis2ns646:nested_exception>com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near ':'.</axis2ns646:nested_exception><axis2ns646:source_data_service>

任何人都知道它可能是什么?

4

2 回答 2

1

我已经尝试过了,因为我的一个同事现在也有这个问题。看来问题是由于语句中的回车(回车)引起的。

试试这样,没有任何回车:

Update Door Set dcr_messageBox = :msg, dcr_servicesArea = :servArea Where dcr_regNo = :regNo

这对我有用。

JC

于 2016-01-15T14:36:26.887 回答
0

在 JDBC 中,变量的默认占位符是?. :msg不支持命名参数的常见用法(独立 JDBC)

您需要将查询转换为

Update Door
 Set dcr_messageBox = ?, dcr_servicesArea =?
  Where dcr_regNo = ?

然后在你的PreparedStatement

ps.setInt(1, msg);
ps.setInt(2, servArea);
ps.setInt(3, regNo);
于 2016-01-15T10:08:52.537 回答