Итак, я разрабатываю приложение CRUD для моего последнего года проекта.У меня есть несколько JFrames с возможностью Create-Update-Delete.Когда я запускаю JFrames отдельно, он выполняет свою работу без каких-либо проблем, то есть Create-Update-Delete.Однако, когда я запускаю приложение целиком (экспорт в виде исполняемого файла JAR), я получаю эту ошибку:
[SQLITE_BUSY] Файл базы данных заблокирован (база данных заблокирована)
Вот детали:
Connection Successful!
Connection Successful!
Connection Successful!
org.sqlite.SQLiteException: [SQLITE_BUSY] The database file is locked (database is locked)
at org.sqlite.core.DB.newSQLException(DB.java:909)
at org.sqlite.core.DB.newSQLException(DB.java:921)
at org.sqlite.core.DB.execute(DB.java:822)
at org.sqlite.core.DB.executeUpdate(DB.java:863)
at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:99)
at main.UsersGUI$2.actionPerformed(UsersGUI.java:177)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
А вот мой код:
JButton updateButton = new JButton("Update");
updateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
String id = userID.getText();
String name = empName.getText();
String surname = empSurname.getText();
String username = usernameField.getText();
String job = jobRoleField.getText();
String sup = supField.getText();
String pro = projectNamefield.getText();
String dept = deptField.getText();
String sql = "update employeesDetails set empName = '"+name+"', empSurname = '"+surname+"', username = '"+username+"', position = '"+job+"'"
+ ", projectName = '"+pro+"', supID = '"+sup+"', department = '"+dept+"' where empID = '"+id+"'";
pst = con.prepareStatement(sql);
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Successfully Updated! Reload the table to see the changes made.", "Updated", JOptionPane.INFORMATION_MESSAGE);
}catch(Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Oops, something went wrong while Updating : " + ex, "Error Updating", JOptionPane.ERROR_MESSAGE);
}finally {
try {
pst.close();
} catch (SQLException e1) {
//ignored
}
}
}
});
Что я сделал не так?Любая помощь приветствуется!Большое спасибо.