SQLITE_BUSY wicket中的数据库文件被锁定(数据库被锁定)

发布于 2024-12-21 16:11:08 字数 1357 浏览 5 评论 0原文

我正在检票口做一个项目 如何解决问题。 我看到这样一条消息: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

じ违心 2024-12-28 16:11:08

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.

请叫√我孤独 2024-12-28 16:11:08

(...) 告诉 sqlite 等待数据库在指定的时间内变得可用。

要从 Java 执行此操作,请像运行简单的 SQL 语句一样运行以下语句:

pragma busy_timeout=30000; -- Busy timeout set to 30000 milliseconds

(...) tell sqlite to wait for the database to become available for specified amount of time.

In order to do it from Java, run the following statement just like a simple SQL statement:

pragma busy_timeout=30000; -- Busy timeout set to 30000 milliseconds
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文