Hi guys I am able to drop my tables that I want but however when I come to trying to drop rows the rows do not delete. I have tried the following which have all produced the same error duplicate key TABLENAME :
Any help you can give for a solution would be very helpful
1. String writeString3 = "DROP TABLE "+t;
2. String writeString3 ="DELETE FROM"+t+"where NAME="+t ;
3. String writeString3 ="DELETE FROM"+t+"where NAME=1" ;
4. String writeString3 ="DELETE FROM TABLENAME WHERE NAME = '1'";
5. String writeString3 ="DROP TABLE testing "; //// it works but when I try
6. String writeString3 ="DROP TABLE"+t; // it gives same error
My code that I have used can be seen below:
if (e.getSource() == DELETERECORDS) {
String t = TABLENAME.getText();
String v = NAME.getText();
String writeString3 ="DROP TABLE testing ";
try {
myStatement.executeUpdate(writeString3);
TABLENAME.setText("");
} catch (SQLException sqle) {
showMessageDialog(this, "Duplicate key " + t);
}
TABLENAME.setText("");
}