Я пытаюсь вставить некоторые значения в MYSQL из Java, используя следующую инструкцию JDB C:
String sql="INSERT INTO abc.example(name,email,salary) VALUES (?,?,?)";
mystmt = myCon.prepareStatement(sql);
System.out.println("enter name");
String name=scan.next();
System.out.println("enter email");
String email=scan.next();
System.out.println("enter salary");
int Salary=scan.nextInt();
mystmt.setString(1,name);
mystmt.setString(2,email);
mystmt.setInt(3,Salary);
int i =mystmt.executeUpdate(sql);
System.out.println(i+"records inserted\n");
Но я получаю это исключение
Exception in thread "main" java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.ClientPreparedStatement.checkBounds(ClientPreparedStatement.java:1372)
at com.mysql.cj.jdbc.ClientPreparedStatement.getCoreParameterIndex(ClientPreparedStatement.java:1385)
at com.mysql.cj.jdbc.ClientPreparedStatement.setString(ClientPreparedStatement.java:1752)
at jdbc1.Preaprex.main(Preaprex.java:36)