【发布时间】:2020-01-29 18:21:36
【问题描述】:
我正在尝试使用 h2database 测试我的 DB2 查询,但在尝试截断表时遇到了问题。
这是我的查询:TRUNCATE TABLE SCHEMA.TABLE_NAME IMMEDIATE
错误:
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "TRUNCATE TABLE TOPACC.STREAM_FORECAST IMMEDIATE[*]"; SQL statement:
TRUNCATE TABLE TOPACC.STREAM_FORECAST IMMEDIATE [42000-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:451)
我的配置:
private Properties hibernateProperties() {
Properties properties = new Properties();
properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
properties.put("hibernate.show_sql", true);
properties.put("hibernate.default_schema", "SCHEMA_NAME");
properties.put("hibernate.connection.driver_class", "org.h2.Driver");
properties.put("hibernate.connection.username", "NAME");
properties.put("hibernate.connection.password", "");
properties.put("hibernate.connection.url", "jdbc:h2:mem:testdb;MODE=DB2;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS SCHEMA_NAME");
properties.put("hibernate.hbm2ddl.auto", "create");
return properties;
}
【问题讨论】:
标签: hibernate junit db2 h2 truncate