I'm trying to update an Entry in my mySQL Database. It works fine with here for example:
String sql = "SELECT * FROM entries WHERE user_id = ?";
PreparedStatement stmt = con.prepareStatement(sql);
stmt.setInt(1, currUserId);
System.out.println("Curr User Id: " + currUserId);
//Execute Query
ResultSet rs = stmt.executeQuery();
But here I just always get an Error and dont know why.
String sql = "UPDATE entries SET ? = ? WHERE user_id = ? AND id = ?";
PreparedStatement stmt = con.prepareStatement(sql);
stmt.setString(1, type);
stmt.setString(2, value);
stmt.setInt(3, App.connection.currUserId);
stmt.setInt(4, id);
int returnValue = stmt.executeUpdate();
This is my Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''username' = 'benNeu' WHERE user_id = 13 AND id = 22' at line 1```