Mybatis---基于字符串拼接进行批量更新的Bug记录

353 阅读1分钟

bad SQL grammar []

写在最前面: 用p6syt可以获取最终sql,跟踪代码后,不建议生产环境使用此插件,会影响性能 其次,为定位问题,也需排除插件带来的可能影响 故驱动:com.mysql.jdbc.Driver

	 
     application-dev.yml
     url: jdbc:mysql://localhost:3306/clms_cps_dev?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&MultiQueries=true
     
     application.yml
     driver-class-name: com.mysql.jdbc.Driver

断点获取sql步骤:

DefaultSqlSession BaseExecutor 进入SimpleExecutor的doUpdate方法 step into后进 PreparedStatementHandler的update方法

这里已经进入mysql-connect-java包了,单击this的view,获得拼接完成的sql,可以在navicat中执行

但是mysql最终通过commmand.send()之前还是String类型的明文可见sql,此时,亦可执行,send()但转换为byte数组后,提交mysql执行器,就会报错badGrammer。问题留存。

待解决!

已知最佳解决方案:将参数拼接为sql,导出到文件,并通过navicat执行,预估效率增幅100倍以上