美文网首页
mysql批量更新

mysql批量更新

作者: 浅浅星空 | 来源:发表于2020-06-10 18:08 被阅读0次
    mysql举例:
    <update id="batchUpdate"  parameterType="java.util.List">
         
           <foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";">
                    update test 
                    <set>
                      test=${item.test}+1
                    </set>
                    where id = ${item.id}
           </foreach>
             
        </update>
    
    问题:
    update test SET PRICE_DESC = ?,                UPDATED_STAMP = now(),         UPDATED_USER = 'system'      where ID = ?   ;      update test SET PRICE_DESC = ?,                UPDATED_STAMP = now(),         UPDATED_USER = 'system'      where ID = ? ;  
    ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update car_price_change_workcard
    
    解决方法:
    mysql数据库采用一下写法即可执行,但是数据库连接必须配置:&allowMultiQueries=true
    
    例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&amp;characterEncoding=UTF-8&allowMultiQueries=true
    

    相关文章

      网友评论

          本文标题:mysql批量更新

          本文链接:https://www.haomeiwen.com/subject/ecwptktx.html