Witam
Próbuję w miejsce placeholderów (czyli '?') podstawić string, który podał nam uzytowkownik.
Błąd, który cały czas wyskakuje to :
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
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Probowałem róznych metod, wstawiania ? w pojedynczy cudzysłow, podwójny itp., ale bez skutku.
System.out.println("First name:");
String first = mReader.readLine();
System.out.println("Last name:");
String last = mReader.readLine();
String insert = "INSERT INTO persons (last, first) VALUES (?,?)";
PreparedStatement preparedStatement = conn.prepareStatement(insert);
preparedStatement.setString(1, first);
preparedStatement.setString(2, last);
preparedStatement.executeUpdate(insert);