Getting [SQLITE_BUSY] database file is locked with select statements

前端 未结 8 2023
广开言路
广开言路 2020-11-28 13:18

If I run multiple threads against my web app I get:

java.sql.SQLException: [SQLITE_BUSY]  The database file is locked (database is locked)
    at org.sqlite.         


        
相关标签:
8条回答
  • 2020-11-28 14:08

    For me the problem was that I was opening too much Sessions So I made the session field in my DAO class static

    0 讨论(0)
  • 2020-11-28 14:10

    Thanks from bowman han, I added a piece of code to his solution and it worked for me.

    private static Connection c = null;
    public static Connection connect() throws Exception {
    
        if (c == null) {
            c = (Connection) DriverManager.getConnection(url);
        } else {
            c.close();
            c = (Connection) DriverManager.getConnection(url);
        }
        return c;
    }
    
    0 讨论(0)
提交回复
热议问题