I can't get my delete method to work:
// delete book
public void deleteBook(String isbn)
{
boolean deleted = false;
try
{
doStatementQuery(bookSQLStatements.RemoveBook(isbn), 3, 1);
statement.close();
bookSQLStatements.CloseDatabase();
deleted = true;
}
catch(SQLException sqlException)
{
System.out.println(sqlException.toString());
deleted = false;
}
if(deleted)
{
JOptionPane.showMessageDialog(null, "Book Details Relating to: " + isbn + " have been deleted", "Deletion Confirmation", 1);
}
else
{
JOptionPane.showMessageDialog(null, "It has not been possible to delete Book Details relating to: " + isbn + "!", "Deletion Confirmation", 1);
}
}
// this method creates a statement from the query passed as an argument
private void doStatementQuery(String query, int execute, int connect)
{
int result = 0;
resultSet = null;
statement = null;
connection = null;
switch(connect)
{
case 1: connection = bookSQLStatements.OpenDatabase();
break;
}
try
{
statement = connection.createStatement();
System.out.println(query);
if(execute == 1)
{
resultSet = statement.executeQuery(query);
}
else if(execute == 2)
{
result = statement.executeUpdate(query);
}
else if (execute == 3)
{
statement.execute(query);
}
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
}
}
// method to remove a book from the database
public String RemoveBook(String isbnIn)
{
return "DELETE FROM Book WHERE ISBN = '" + isbnIn + "'";
}
is about all of the methods that it relates to, it's not throwing an error but it's also not working. Thank you for any help that you can give, Wonkey