SQLITE_BUSY wicket 中的数据库文件被锁定(数据库被锁定) [英] SQLITE_BUSY The database file is locked (database is locked) in wicket

查看:46
本文介绍了SQLITE_BUSY wicket 中的数据库文件被锁定(数据库被锁定)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 wicket 做一个项目如何解决问题.我遇到了这样的消息:WicketMessage:无法使用构造函数 public itucs.blg361.g03.HomePage() 来实例化页面

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()

根本原因:

java.lang.UnsupportedOperationException: [SQLITE_BUSY] 数据库文件被锁定(数据库被锁定)在 itucs.blg361.g03.CategoryEvents.CategoryEventCollection.getCategoryEvents(CategoryEventCollection.java:41)

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;  
}

在 itucs.blg361.g03.HomePage.(HomePage.java:71)

at itucs.blg361.g03.HomePage.(HomePage.java:71)

        categories = categoryCollection.getCategoryEvents();

在 java.lang.reflect.Constructor.newInstance(Constructor.java:525)

at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

推荐答案

Sqlite 一次只允许一个写入器写入整个数据库,除非您选择了WAL"日志模式,否则写入时没有读取器.此外,除非您明确要求它等待,否则它只会在冲突操作运行时为任何访问数据库的尝试返回 SQLITE_BUSY 状态.

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.

您可以告诉 sqlite 在指定的时间内等待数据库变为可用.C 级 API 为 sqlite3_busy_timeout;不过我从来没有用过 Java 中的 sqlite,所以我不知道在哪里可以找到它.

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.

这篇关于SQLITE_BUSY wicket 中的数据库文件被锁定(数据库被锁定)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆