org.springframework.jdbc.UncategorizedSQLException异常其中的一种情况

异常:

org.springframework.jdbc.UncategorizedSQLException: 
### Error updating database.  Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'     a.vehicle_type = ? 
      wher', expect IDENTIFIER, actual IDENTIFIER pos 299, line 11, column 11, token IDENTIFIER a : update cims_charge_rule a
       SET a.init_price = ?,
        a.init_mileage = ?,
        a.time_price = ?,
        a.mileage_price = ?,
        a.long_distance_price = ?,
        a.long_distance_mileage = ?,
        a.out_town_price = ?,
        a.order_type = ?,
        a.immediacy = ?
        a.vehicle_type = ? 
      where
      a.id = ?

Caused by: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'     a.vehicle_type = ? 
      wher', expect IDENTIFIER, actual IDENTIFIER pos 299, line 11, column 11, token IDENTIFIER a : update cims_charge_rule a
       SET a.init_price = ?,
        a.init_mileage = ?,
        a.time_price = ?,
        a.mileage_price = ?,
        a.long_distance_price = ?,
        a.long_distance_mileage = ?,
        a.out_town_price = ?,
        a.order_type = ?,
        a.immediacy = ?
        a.vehicle_type = ? 
      where
      a.id = ?

Caused by: com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'     a.vehicle_type = ? 
      wher', expect IDENTIFIER, actual IDENTIFIER pos 299, line 11, column 11, token IDENTIFIER a

经过检查发现

<update id="updateCharge" parameterType="*****">
  update cims_charge_rule a
    <set>
      <if test="initPrice != null">a.init_price = #{initPrice},</if>
      <if test="initMileage != null">a.init_mileage = #{initMileage},</if>
      <if test="timePrice != null">a.time_price = #{timePrice},</if>
      <if test="mileagePrice != null">a.mileage_price = #{mileagePrice},</if>
      <if test="longDistancePrice != null">a.long_distance_price = #{longDistancePrice},</if>
      <if test="longDistanceMileage != null">a.long_distance_mileage = #{longDistanceMileage},</if>
      <if test="outTownPrice != null">a.out_town_price = #{outTownPrice},</if>
      <if test="orderType != null || orderType != ''">a.order_type = #{orderType},</if>
      <if test="immediacy != null || immediacy != ''">a.immediacy = #{immediacy,}</if>
      <if test="vehicleType != null || vehicleType != ''">a.vehicle_type = #{vehicleType}</if>
    </set>
    where
    a.id = #{id}
</update>

 

 

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值