0

i have a very terrible problem now with SQLite database. I used it for an app development and it runs well without no exception errors on my computer. but when I run the app on another pc, I get a pop-up saying SQLite database is locked..i click on it many times before the app opens and it works fine. but if I close the app and attempt to open it again, the same 'sqlite database lock exception pops up' and its very disturbing. please how do I solve this problem. thanks

Rodney Nart
  • 121
  • 11

3 Answers3

0

That probably means the handle for the database was not closed/disposed correctly.

You need to call conn.close(); when the application is going to be closed, see this answer

0
 public static Connection connectDB(){
    try{
    String sys =System.getProperty("user.home");
    Class.forName("org.sqlite.JDBC");
    Connection conn = DriverManager.getConnection("jdbc:sqlite:"+sys+"\\Desktop\\hyper-DB\\database.sqlite3");
    return conn;
    }catch(ClassNotFoundException | SQLException e){
    JOptionPane.showMessageDialog(null, e);
    return null;
    } 
}

please the above code is for the SQLite connection.. please what haven't I done right.

Rodney Nart
  • 121
  • 11
0

Don't forget to close the connection.

// in your code
connection.close()
mike_t
  • 2,484
  • 2
  • 21
  • 39