I have a database and I need to insert a new record there. I try to use PreparedStatement.
//Executing the INSERT query
String addSql = "INSERT INTO savedforms (Patientfnr, Patientname) VALUES (?, ?)";
//PreparedStatement for INSERT sql
java.sql.PreparedStatement stmt1 = connection.prepareStatement(addSql);
stmt1.setString(1, patientnumber);
stmt1.setString(2, patientname);
//Execute query
stmt1.executeUpdate(addSql);
and get the following error:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 '?, ?)' at line 1
how it can be fixed?