我已经编写了一些访问h2表的测试用例。其中一个测试用例失败,并显示以下错误
### Error updating database. Cause: org.h2.jdbc.JdbcSQLException: Timeout trying to lock table ; SQL statement:
INSERT INTO ABC.MY_TABLE(
COL1,
COL2
)
VALUES(
?,
?
) [50200-197]
### The error may involve com.abc.api.dao.MyMapper.addDataInTable-Inline
### The error occurred while setting parameters
...
org.apache.ibatis.exceptions.PersistenceException:
...
Caused by: org.h2.jdbc.JdbcSQLException: Concurrent update in table "MY_TABLE": another transaction has updated or deleted the same row [90131-197]
我尝试了here中提到的解决方案。我尝试过
private static DataSource dataSource = new DriverManagerDataSource("jdbc:h2:mem:ODS;MODE=Oracle;DB_CLOSE_DELAY=-1;MVCC=true");
和
private static DataSource dataSource = new DriverManagerDataSource("jdbc:h2:mem:ODS;MODE=Oracle;DB_CLOSE_DELAY=-1;MVCC=true;DEFAULT_LOCK_TIMEOUT=10000");
甚至
private static DataSource dataSource = new DriverManagerDataSource("jdbc:h2:mem:ODS;MODE=Oracle;DB_CLOSE_DELAY=-1;AUTOCOMMIT=ON");
但是没有用。有人可以帮我吗?