I am at wits end with a Java web app that will not run a delete in Mysql. I get no errors, and when I copy and paste my query into the Mysql workbench, it does what it is supposed to. SELECT
and INSERT
both work for this table in my code.
Here is my code:
public void deleteParticipant(String email){
try{
connect();
PreparedStatement pst = conn.prepareStatement(
"DELETE FROM activity_connections WHERE user_email=? AND activity_id=? LIMIT 1"
);
pst.setString(1, email);
pst.setString(2, this.id);
pst.executeUpdate();
pst.close();
conn.close();
}catch(ClassNotFoundException ce){
System.out.println("Driver error: " + ce);
ce.printStackTrace();
}catch(SQLException se){
System.out.println("SQL error: " + se);
se.printStackTrace();
}
}
And here is the connect method
protected static Connection conn;
public static String CONNECTION_STRING = "jdbc:mysql://localhost/kokosole?autoReconnect=true&useSSL=false";
public static String USERNAME = "root";
public static String PASSWORD = "password123";
protected static void connect() throws SQLException, ClassNotFoundException {
String driver = "com.mysql.jdbc.Driver";
String url = CONNECTION_STRING;
Class.forName(driver);
conn = DriverManager.getConnection(url, USERNAME, PASSWORD);
}
Why is this not working?