Java JDBC: trouble deleting SQL rows from online database?

I am using this free resource to store a MySQL database:

There is a delete button in my program which deletes an image that the user chooses from a list of images. The problem is that I have the page set to close and refresh the JList by opening up a new JFrame with the deleted image removed from the list. But the actual frame refresh happens faster than the row can be deleted from the online database (which takes about 5 seconds) which results in the image remaining in the JList and crashing it. Is there any type of boolean statement where I can execute some lines after a prepared statement after I detect it has sucessfully executed?

There is nothing wrong with my delete statements, I separately tested them and they are deleting as they should be in the database so I think the problem is that my application is just refreshing faster than SQL can delete the row.

I tried doing something similar to this but had no success:

int i=stmt.executeUpdate();
         System.out.println("stuck somewhere");