0

请问我有问题。我使用 java 创建了一个 GUI 应用程序,我目前使用 SQLite 作为我的数据库。

该应用程序起初运行良好,但目前我不断收到此错误

java.sql.SQLException: [SQLITE_BUSY]  The database file is locked (database is locked)
Jul 18, 2021 8:53:43 PM db.LecturalQueries addLectural
SEVERE: null
java.sql.SQLException: [SQLITE_BUSY]  The database file is locked (database is locked)
at org.sqlite.core.DB.newSQLException(DB.java:890)
at org.sqlite.core.DB.newSQLException(DB.java:901)
at org.sqlite.core.DB.execute(DB.java:807)
at org.sqlite.jdbc3.JDBC3PreparedStatement.execute(JDBC3PreparedStatement.java:50)
at db.LecturalQueries.addLectural(LecturalQueries.java:46)
at studentmanagmentsystem.AddLectural.AddbtnActionPerformed(AddLectural.java:367)





//the code to handle adding a new Lecturals
public void addLectural(String[] details){
    
   try {
       // the insert statment
       String sql = "insert into Lecturals"
               +"(LecturalName,CourseID,Email,Password)"
               +"values(?,?,?,?)";
       // loading the statement into the connection so it can be executed
       pst = con.prepareStatement(sql);
       //passing in the values
       pst.setString(1, details[0]);
       pst.setInt(2, Integer.parseInt(details[1]));
       pst.setString(3, details[2]);
       pst.setString(4, details[3]);
       //executing the query
       pst.execute();
       
       //popping up a sccess message
       JOptionPane.showMessageDialog(null, "Lectural Added Successfully!");
       
   } catch (SQLException ex) {
       System.out.println(ex);
       Logger.getLogger(CoursesQueries.class.getName()).log(Level.SEVERE, null, ex);
       JOptionPane.showMessageDialog(null, "Error while adding Lectural");
   }
}

我在不同的包上创建了连接和讲座查询,并使用适当的对象名称将其调用到 Jform GUI,我只是找不到问题。另外,我尝试关闭连接,但是当我这样做时它仍然不起作用。

在进入这个添加界面之前,我有一个登录页面和一些其他连接,我也关闭了这些连接,但仍然收到错误消息。

4

0 回答 0