请。我正在尝试从表中删除一行,同时从sqlite .bute中删除一行我收到此错误:
enter java.sql.SQLException: database is locked
at org.sqlite.NativeDB.throwex(NativeDB.java:210)
at org.sqlite.NativeDB._exec(Native Method)
at org.sqlite.Stmt.executeUpdate(Stmt.java:152)
at agenda_p4.Principal.DeleteUser(Principal.java:328)
at agenda_p4.Principal.jButton4ActionPerformed(Principal.java:299)
at agenda_p4.Principal.access$300(Principal.java:33)
at agenda_p4.Principal$4.actionPerformed(Principal.java:184)*
enter code here public void DeleteUser(String v){
String nombreEliminar = v;
System.err.print("NOMBRE A ELIMINRA ES " +nombreEliminar);
DefaultTableModel modelo = (DefaultTableModel) this.jTable1.getModel();
int i = jTable1.getSelectedRow();
String nombre = (String) jTable1.getValueAt(i, 0);
if (i == -1) {
JOptionPane.showMessageDialog(null, "Debes selecioonar una fila");
} else {
int ax = JOptionPane.showConfirmDialog(null,
"Estás seguro de que quieres eliminar este registro?");
if (ax == JOptionPane.YES_OPTION) {
try {
st = con.createStatement();
} catch (SQLException ex) {
Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
}
try {
//THE ERROR IS THERE IN st.esxecuteupdate:
st.executeUpdate("delete from Contactos where NombreCompleto =
'" + nombre + "' AND user = '" + nombreEliminar + "'");
JOptionPane.showMessageDialog(null, "Contacto eliminado");
modelo.removeRow(jTable1.getSelectedRow());
} catch (SQLException ex) {
System.out.print(ex.getMessage());
JOptionPane.showMessageDialog(null, "No se ha podido eliminar el contacto");
Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
}
} else if (ax == JOptionPane.NO_OPTION) {
JOptionPane.showMessageDialog(null, "Has seleccionado NO.");
}
}
我不得不说我对同时工作的其他方法有更多的疑问。
谢谢!