It gives this error:
"java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0). "
This is the code:
public void insertData(int id,String name, String status, String age){
String sql = "INSERT INTO student_table (id,name,satus,age) VALUES (id,name,status,age)";
try (Connection conn1 = this.connects();PreparedStatement Prepst= conn1.prepareStatement(sql)){
Prepst.setInt(1, id);
Prepst.setString(2, name);
Prepst.setString(3, status);
Prepst.setString(4, age);
Prepst.executeUpdate();
}catch(Exception e){
System.err.println(e);
}
If I change the parameter index to another value i.e.:
Prepst.setInt(0, id);
then it gives this error:
" java.sql.SQLException: Parameter index out of range (0 < 1 ). "
----UPDATE -----
I inserted this code:
String sql = "INSERT INTO student_table (id,name,satus,age) VALUES (?,?,?,?)";
It produces the same:
Table Structure:

(?,?,?,?)is correct, but the first parameter is at position 1, not 0.status, notsatus? Anyway, your question is answered. Please don't extend it with "help me debug my code until I get the correct result" comments.