数据库 SQLServer转MySQL数据

网友投稿 276 2023-11-25

bug简述:sql由SQLServer转换成MySQL后,navicat下可以执行,项目中却报错。

报错如下:

数据库 SQLServer转MySQL数据库

1-1

### Error querying database. 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 Create TEMPORARY TABLE temp_table3

select * from (

select * from VIEW_UserMe at line 2

### The error may exist in XX/XXX/XXXX/XXXXX/mapper/XXXXXMapper.xml

### The error may involve defaultParameterMap

### The error occurred while setting parameters

### SQL: Drop TEMPORARY TABLE IF exists temp_table3; Create TEMPORARY TABLE temp_table3 select * from ( select * from VIEW_UserMeter where supplierID =1 and SampleTime between date_sub(NOW(),interval 1 day) and date_add(NOW(),interval 1 day) ) as a; select * from (SELECT ROW_NUMBER() OVER ( ORDER BY sampleTime ) AS rownumber , building,entrance,doorplate,village,userName,remark1,remark2,meterId,meterSize,total,pressure,flowRate,valveStatus,status,updateTime,timeInp,vol,operate_ValveStatus,sampleTime,t1Inp FROM temp_table3 ) cc WHERE cc.rownumber > 0 limit 50; Drop TEMPORARY TABLE IF exists temp_table3;

### 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 Create TEMPORARY TABLE temp_table3

select * from (

select * from VIEW_UserMe at line 2

; bad SQL grammar []; nested exception is 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 Create TEMPORARY TABLE temp_table3

select * from (

select * from VIEW_UserMe at line 2

.....................................................

将sql粘出执行,如下图,可成功执行,查询出结果,排除转换出错的可能:

1-2

回过头查看控制台error:

### The error may involve defaultParameterMap

### The error occurred while setting parameters

考虑到是不是MyBatis不支持在XML配置的SQL中带有分号“;”。

经查询,开启了allowMultiQueries=true,MyBatis即可支持批量处理sql.

如下图:

1-3

重新启动项目,可成功执行,问题解决。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub-/31557424/viewspace-2219998/,如需转载,请注明出处,否则将追究法律责任。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Redis热点数据问题怎么解决
下一篇:mysql的DML进阶、分页查找、SQL约束及多表操作方法
相关文章

 发表评论

暂时没有评论,来抢沙发吧~