我是HSQLDB的新手,刚收到此错误,我无法在互联网上找到任何解决方案,似乎我错过了一些东西^^
我的应用程序目前没有做任何事情,除非创建两个表已经存在。
这是我处理HSQLDB的代码:
try {
Class.forName("org.hsqldb.jdbc.JDBCDriver" );
} catch (Exception e) {
System.err.println("ERROR: failed to load HSQLDB JDBC driver.");
e.printStackTrace();
return;
}
try {
connection = DriverManager.getConnection("jdbc:hsqldb:file:"+mi.getDataFolder().getPath()+"\\data\\storage;hsqldb.lock_file=false", "SA", "");
connection.prepareStatement(
"CREATE TABLE IF NOT EXISTS Punishments (" +
"id INTEGER IDENTITY PRIMARY KEY," +
"name VARCHAR(16)," +
"uuid VARCHAR(35)," +
"reason VARCHAR(100)," +
"operator VARCHAR(16)," +
"punishmentType VARCHAR(16)," +
"start BIGINT," +
"end BIGINT," +
"calculation VARCHAR(50))"
).execute();
connection.prepareStatement(
"CREATE TABLE IF NOT EXISTS PunishmentHistory (" +
"id INTEGER IDENTITY PRIMARY KEY," +
"name VARCHAR(16)," +
"uuid VARCHAR(35)," +
"reason VARCHAR(100)," +
"operator VARCHAR(16)," +
"punishmentType VARCHAR(16)," +
"start BIGINT," +
"end BIGINT," +
"calculation VARCHAR(50))"
).execute();
} catch (SQLException e) {
e.printStackTrace();
}
我运行代码的前两次左右,它运行正常,但在某些时候,我不断收到此错误:
[22:22:21 FATAL]: statement error processing log - open continuedplugins\AdvancedBan\data\storage.log line: 2
org.hsqldb.HsqlException: integrity constraint violation: unique constraint or index violation; BLOCKS_PK table: BLOCKS
at org.hsqldb.error.Error.error(Unknown Source) ~[AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.Constraint.getException(Unknown Source) ~[AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.index.IndexAVLMemory.insert(Unknown Source) ~[AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.persist.RowStoreAVL.indexRow(Unknown Source) ~[AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.TransactionManager2PL.addInsertAction(Unknown Source) ~[AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.Session.addInsertAction(Unknown Source) ~[AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.Table.insertNoCheckFromLog(Unknown Source) ~[AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.persist.ScriptRunner.runScript(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.persist.ScriptRunner.runScript(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.persist.Log.processLog(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.persist.Log.open(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.persist.Logger.open(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.Database.reopen(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.Database.open(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.DatabaseManager.getDatabase(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.DatabaseManager.newSession(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
at java.sql.DriverManager.getConnection(Unknown Source) [?:1.8.0_111]
at java.sql.DriverManager.getConnection(Unknown Source) [?:1.8.0_111]
at me.leoko.advancedban.manager.DatabaseManager.setup(DatabaseManager.java:69) [AdvancedBan-2.0.6-SNAPSHOT.jar:?]
[...]
这是我收到错误后.log文件的示例:
/*C1*/SET SCHEMA SYSTEM_LOBS
INSERT INTO BLOCKS VALUES(0,2147483647,0)
COMMIT
/*C2*/SET SCHEMA PUBLIC
CREATE TABLE IF NOT EXISTS Punishments (id INTEGER IDENTITY PRIMARY KEY,name VARCHAR(16),uuid VARCHAR(35),reason VARCHAR(100),operator VARCHAR(16),punishmentType VARCHAR(16),start BIGINT,end BIGINT,calculation VARCHAR(50))
CREATE TABLE IF NOT EXISTS PunishmentHistory (id INTEGER IDENTITY PRIMARY KEY,name VARCHAR(16),uuid VARCHAR(35),reason VARCHAR(100),operator VARCHAR(16),punishmentType VARCHAR(16),start BIGINT,end BIGINT,calculation VARCHAR(50))
DISCONNECT
/*C4*/SET SCHEMA PUBLIC
CREATE TABLE IF NOT EXISTS Punishments (id INTEGER IDENTITY PRIMARY KEY,name VARCHAR(16),uuid VARCHAR(35),reason VARCHAR(100),operator VARCHAR(16),punishmentType VARCHAR(16),start BIGINT,end BIGINT,calculation VARCHAR(50))
CREATE TABLE IF NOT EXISTS PunishmentHistory (id INTEGER IDENTITY PRIMARY KEY,name VARCHAR(16),uuid VARCHAR(35),reason VARCHAR(100),operator VARCHAR(16),punishmentType VARCHAR(16),start BIGINT,end BIGINT,calculation VARCHAR(50))
DISCONNECT
/*C3*/SET SCHEMA PUBLIC
CREATE TABLE IF NOT EXISTS Punishments (id INTEGER IDENTITY PRIMARY KEY,name VARCHAR(16),uuid VARCHAR(35),reason VARCHAR(100),operator VARCHAR(16),punishmentType VARCHAR(16),start BIGINT,end BIGINT,calculation VARCHAR(50))
CREATE TABLE IF NOT EXISTS PunishmentHistory (id INTEGER IDENTITY PRIMARY KEY,name VARCHAR(16),uuid VARCHAR(35),reason VARCHAR(100),operator VARCHAR(16),punishmentType VARCHAR(16),start BIGINT,end BIGINT,calculation VARCHAR(50))
DISCONNECT
/*C3*/SET SCHEMA PUBLIC
CREATE TABLE IF NOT EXISTS Punishments (id INTEGER IDENTITY PRIMARY KEY,name VARCHAR(16),uuid VARCHAR(35),reason VARCHAR(100),operator VARCHAR(16),punishmentType VARCHAR(16),start BIGINT,end BIGINT,calculation VARCHAR(50))
CREATE TABLE IF NOT EXISTS PunishmentHistory (id INTEGER IDENTITY PRIMARY KEY,name VARCHAR(16),uuid VARCHAR(35),reason VARCHAR(100),operator VARCHAR(16),punishmentType VARCHAR(16),start BIGINT,end BIGINT,calculation VARCHAR(50))
我使用的是HSQLDB版本2.4.0,但也尝试使用旧版本
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.4.0</version>
<scope>compile</scope>
</dependency>
提前感谢您的任何建议。
答案 0 :(得分:1)
当我的应用程序被关闭时,我不得不最后调用“SHUTDOWN”SQL命令,并不时调用“CHECKPOINT”SQL命令。
感谢您帮助我解决这个问题。