Getting [SQLITE_BUSY] database file is locked with select statements

前端 未结 8 2032
广开言路
广开言路 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:06

    There should be only ONE connection with your application. you can use this to ensure.

    public class SqliteHelper {
    private static Connection c = null;
    public static Connection getConn() throws Exception {
        if(c == null){
        Class.forName("org.sqlite.JDBC");
        c = DriverManager.getConnection("jdbc:sqlite:D:/test.db");
        }
        return c;
        }
    }
    

提交回复
热议问题