Strange Problem...
im using a method to delete contacts from a database but when i change it it doesnt wanna work, eventhough itseems like it should. this is the original working method:
publicvoid deleteContact(String contactName){
try{
preparedStatement = connection.prepareStatement("delete from CONTACTS where NAME = ?");
preparedStatement.setString(1, contactName);
preparedStatement.executeUpdate();
}catch(SQLException ex){
ex.printStackTrace();
}
}
this is how i use it in my application:
contactIO.deleteContact(contactName);
obviously this is bad because if 2 or more contacts have the same name they are all deleted from the database. so i modified the method to this:
publicvoid deleteContact(String contactName, String contactNumber, String contactEMail){
try{
preparedStatement = connection.prepareStatement("delete from CONTACTS where NAME = ?, NUMBER = ?, EMAIL = ?");
preparedStatement.setString(1, contactName);
preparedStatement.setString(2, contactNumber);
preparedStatement.setString(3, contactEMail);
preparedStatement.executeUpdate();
}catch(SQLException ex){
ex.printStackTrace();
}
}
and this is how i use it:
contactIO.deleteContact(contactName, contactNumber, contactEMail);
now it doesnt work :(. any help would really be appreciate because i have no clue what is wrong
[2077 byte] By [
Alex1989a] at [2007-11-27 5:34:38]

k thnx guys! that solved most of my problem but now i have another one! when i click on the delete button my application freezes and then after about 2 minutes it deletes the contact, i get this exception:
java.sql.SQLTransactionRollbackException: A lock could not be obtained within the time requested
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.executeUpdate(Unknown Source)
at JavaPhonebook.ContactIO.deleteContact(ContactIO.java:111)
at JavaPhonebook.ContactPanel.buildDeleteDialog(ContactPanel.java:134)
at JavaPhonebook.ContactPanel.actionPerformed(ContactPanel.java:177)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: org.apache.derby.client.am.SqlException: A lock could not be obtained within the time requested
at org.apache.derby.client.am.Statement.completeExecute(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.readExecute(Unknown Source)
at org.apache.derby.client.net.StatementReply.readExecute(Unknown Source)
at org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.readExecute(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.executeUpdateX(Unknown Source)
... 29 more