SQLITE_BUSY wicket中的数据库文件被锁定(数据库被锁定)
我正在检票口做一个项目 如何解决问题。 我看到这样一条消息: WicketMessage: Can't instantiate page using constructor public itucs.blg361.g03.HomePage()
Root Cause:
java.lang.UnsupportedOperationException: [SQLITE_BUSY] 数据库文件被锁定(数据库被锁定) 在 itucs.blg361.g03.CategoryEvents.CategoryEventCollection.getCategoryEvents(CategoryEventCollection.java:41)
public List<CategoryEvent> getCategoryEvents() {
List<CategoryEvent> categoryEvents = new
LinkedList<CategoryEvent>();
try {
String query = "SELECT id, name, group_id"
+ " FROM event_category";
Statement statement = this.db.createStatement();
ResultSet result = statement.executeQuery(query);
while (result.next()) {
int id = result.getInt("id");
String name = result.getString("name");
int group_id = result.getInt("group_id");
categoryEvents.add(new CategoryEvent(id, name, group_id));
}
} catch (SQLException ex) {
throw new UnsupportedOperationException(ex.getMessage());
}
return categoryEvents;
}
在 itucs.blg361.g03.HomePage.(HomePage.java:71)
categories = categoryCollection.getCategoryEvents();
在 java.lang.reflect.Constructor.newInstance(Constructor.java:第525章)
I am doing a project in wicket
How to solve the problem.
I came across such a message:
WicketMessage: Can't instantiate page using constructor public itucs.blg361.g03.HomePage()
Root cause:
java.lang.UnsupportedOperationException: [SQLITE_BUSY] The database file is locked (database is locked)
at itucs.blg361.g03.CategoryEvents.CategoryEventCollection.getCategoryEvents(CategoryEventCollection.java:41)
public List<CategoryEvent> getCategoryEvents() {
List<CategoryEvent> categoryEvents = new
LinkedList<CategoryEvent>();
try {
String query = "SELECT id, name, group_id"
+ " FROM event_category";
Statement statement = this.db.createStatement();
ResultSet result = statement.executeQuery(query);
while (result.next()) {
int id = result.getInt("id");
String name = result.getString("name");
int group_id = result.getInt("group_id");
categoryEvents.add(new CategoryEvent(id, name, group_id));
}
} catch (SQLException ex) {
throw new UnsupportedOperationException(ex.getMessage());
}
return categoryEvents;
}
at itucs.blg361.g03.HomePage.(HomePage.java:71)
categories = categoryCollection.getCategoryEvents();
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Sqlite 一次只允许一名写入者写入整个数据库,并且除非您选择“WAL”日志模式,否则写入时没有读取者。此外,除非您明确要求它等待,否则它只会在冲突操作运行时尝试访问数据库时返回 SQLITE_BUSY 状态。
您可以告诉 sqlite 等待数据库在指定的时间内变得可用。 C级API是
sqlite3_busy_timeout
;但我从未使用过 Java 中的 sqlite,所以我不知道在哪里可以找到它。Sqlite allows only one writer to the whole database at a time and, unless you selected "WAL" journal mode, no reader while writing. Moreover unless you explicitly ask it to wait, it simply returns the SQLITE_BUSY status for any attempt to access the database while conflicting operation is running.
You can tell sqlite to wait for the database to become available for a specified amount of time. The C-level API is
sqlite3_busy_timeout
; I never used sqlite from Java though, so I don't know where to find it there.要从 Java 执行此操作,请像运行简单的 SQL 语句一样运行以下语句:
In order to do it from Java, run the following statement just like a simple SQL statement: