使用Mybatis时由于粗心遇到Cause: java.sql.SQLException: sql injection violation异常

使用Mybatis插入数据时,由于粗心书写错误导致出现Cause: java.sql.SQLException: sql injection violation异常,SQL语句如下:


 <insert id="insertProduct"
            parameterType="com.isoftstone.product.entity.ProductBean">
        insert into mmall_product
        (
        <include refid="baseInsertSql"/>
        )
        values (
          #{productId}, #{categoryId}, #{productName}, ${subtitle},
          #{mainImage}, #{subImages}, #{detail}, #{productPrice},
          #{stock}, #{status},
          <choose>
              <when test="createTime != null">
                  #{createTime},
              </when>
              <otherwise>
                  now(),
              </otherwise>
          </choose>
          <choose>
              <when test="updateTime != null">
                  #{updateTime}
              </when>
              <otherwise>
                  now()
              </otherwise>
          </choose>
        )
    </insert>

异常详细堆栈信息如下: 

org.springframework.jdbc.UncategorizedSQLException: 
### Error updating database.  Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error. pos 237, line 9, column 26, token IDENTIFIER phone : insert into mmall_product
        (
         
        id, category_id, name, subtitle, main_image, sub_images,
        detail, price, stock, status, create_time, update_time
     
        )
        values (
          ?, ?, ?, hello phone,
          ?, ?, ?, ?,
          ?, ?,
           
                  now(),
               
           
                  now()
               
        )
### SQL: insert into mmall_product         (                   id, category_id, name, subtitle, main_image, sub_images,         detail, price, stock, status, create_time, update_time               )         values (           ?, ?, ?, hello phone,           ?, ?, ?, ?,           ?, ?,                               now(),                                               now()                         )
### Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error. pos 237, line 9, column 26, token IDENTIFIER phone : insert into mmall_product
        (
         
        id, category_id, name, subtitle, main_image, sub_images,
        detail, price, stock, status, create_time, update_time
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值