85. UncategorizedSQLException error reporting
The reason for the problem:
There is no such problem in itself. Later, a table on the server was deleted by mistake. After recreating, this problem appeared
org.springframework.jdbc.UncategorizedSQLException:
### Error updating database. Cause: 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.
### The error may involve com.mintel.teacher.mapper.MintMapper.updateUserextend-Inline
### The error occurred while setting parameters
Navigate to the location in the code:
Code error display
applyObjectMapper.insert(applyObject); insert statement error
public Result<?> addOneOrCode(RequestCs cs) {
xxx
xxxx
xxx
String objectId = applyObjectMapper.getSelectQueryno(orCodeList.getClueid(), item.getQueryno());
xxx
xxx
if (ObjectUtil.isNull(objectId) || "".equals(objectId)) {
applyObjectMapper.insert(applyObject);
} else {
applyObject.setId(objectId);
}
List<QueryItem> queryItemList = item.getQueryItemList();
return result.ok();
}
Check the location of the error report, and found that a table was updated above, and the data of another table below was updated, and the data below reported an error
Then check the database and find that the ENGINE of these two tables are InnoDB (the first table) and MyISAM (the second table)
InnoDB: Supports transactions, row-level locking, and foreign keys supports transactions, row-level locks and foreign keys, while MyISAM does not support transactions.
Just change both to InnoDB
Caveats : Updates to non-transactional tables should only be made within autocommit statements or single-statement transactions, and never update transactional tables within the same statement.