I'm currently new to JAVAfx and I am trying to create a signup user method. When I run the program I get this error:
java.sql.SQLException: No value specified for parameter 2
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:379)
at com.example.demo2/com.example.demo2.DatabaseHandler.signUpUser(DatabaseHandler.java:34)
at com.example.demo2/com.example.demo2.registerController.lambda$initialize$0(registerController.java:37)
public void signUpUser(String firstName, String lastName, String email, String password) {
String insert = "INSERT INTO " + Const.USERS_TABLE + "(" + Const.USERS_FIRSTNAME + "," + "VALUES(????)";
try {
PreparedStatement preparedStatement = getDbConnection().prepareStatement(insert);
preparedStatement.setString(1,firstName);
preparedStatement.setString(1,lastName);
preparedStatement.setString(1,email);
preparedStatement.setString(1,password);
preparedStatement.execute();
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
Any help would be great. I think this method is faulty.
Thanks