嘗試更新表中的多個列值。我缺少什么,有點幫助!該dao方法就像... Plan類的所有字段都填充了適當的數據。dao public void updatePlan(Plan plan) { SqlParameterSource mapSqlParameterSource = new MapSqlParameterSource().addValue("id", plan.getId()) .addValue("plan_name", plan.getPlan()) .addValue("price_category", plan.getPrice_category()) .addValue("updated_by", subscriptionPlan.getId()); String UPDATE_PLAN = "UPDATE plan_table SET(plan_name= :plan_name, price_category= :price_category, updated_by= :id) where id=:id)"; SqlParameterSource parameterSource = new BeanPropertySqlParameterSource(subscriptionPlan); namedParameterJdbcTemplate.update(UPDATE_PLAN, mapSqlParameterSource);}錯誤是...(MySQL 數據庫 - 5.6.43,工作臺 - 6.3.9)org.springframework.jdbc.BadSqlGrammarException:PreparedStatementCallback; 錯誤的 SQL 語法 [update webstat_plan set (plan_name= ?, price_category= ?, updated_by= ?) where id=?)]; 嵌套異常是 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的 SQL 語法有錯誤;檢查與您的 MySQL 服務器版本相對應的手冊以獲取正確的語法....
1 回答
MMMHUHU
TA貢獻1834條經驗 獲得超8個贊
問題在于您的 SQL 查詢。更新表時不需要括號。
更新您的查詢
UPDATE plan_table SET plan_name= :plan_name, price_category= :price_category, updated_by= :id where id=:id
添加回答
舉報
0/150
提交
取消
