今天搬砖的时候后台报了一个错误,但是我检查了一遍代码没有发现任何错误。 错误信息如下: StatementCallback; uncateGorized sqlException for SQL [delete from t
今天搬砖的时候后台报了一个错误,但是我检查了一遍代码没有发现任何错误。
错误信息如下:
StatementCallback; uncateGorized sqlException for SQL [delete from tablename where id = 1]; SQL state [HY000]; error code [1785]; Statement violates GTID consistency: Updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.; nested exception is java.sql.SQLException: Statement violates GTID consistency: Updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.
经过排除,发现进行批量更新的表其中有一个表的引擎是用的MyISAM,估计是当初设计表的时候弄错了。
平时开发时,大部分的情况下对数据进行更新操作都需要用到事务,以便发生错误时进行回滚。但是存储引擎为MyISAM的数据表是不支持事务的,如果不清楚可以看这个:InnoDB和MyISAM的区别,或者自行百度。
并不是所有的表都用InnoDB最好,还是得看具体的应用场景,但是这里使用InnoDB肯定没问题。那最后解决办法也很简单,就是把表的引擎改成innodb,命令如下:alter table tablename
engine=innodb
来源地址:https://blog.csdn.net/fei_thefirst/article/details/128854740
--结束END--
本文标题: uncategorized SQLException for SQL错误解决
本文链接: https://www.lsjlt.com/news/376490.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-06-06
2024-06-06
2024-06-05
2024-06-04
2024-06-04
2024-06-03
2024-06-03
2024-06-03
2024-06-04
2024-06-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0