java - 如何解决 JDBC 和 GUI 中的 SQLite [数据库锁定] 问题
问题描述
请问我有问题。我使用 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,我只是找不到问题。另外,我尝试关闭连接,但是当我这样做时它仍然不起作用。
在进入这个添加界面之前,我有一个登录页面和一些其他连接,我也关闭了这些连接,但仍然收到错误消息。
解决方案
推荐阅读
- count - 如何计算代理并将数字保存到变量中
- node.js - SMART on FHIR @asymmetrik/sof-strategy introspectionUrl 工作流程
- c# - 有没有办法将一个数据集的多个实例传递给reportviewer?
- hibernate - Spring-data 在运行时配置和初始化数据库的好方法
- gstreamer - 合并多个分支(队列)时GStreamer如何管理线程
- apache-spark - 使用 Spark DataFrame 或 RDD API 解析具有不同模式的嵌套 JSON 结构
- laravel - 在 laravel 中每次测试后重置 Redis 数据库
- c++ - 树中的内存分配
- javascript - 如何自定义地图并删除“POI 图层”?
- regex - 使用 JMeter 正则表达式提取器中的正则表达式匹配多个换行符