I'm trying to insert a variable into the database.
Heres my code :
public static void main(String[] args) throws SQLException {
Connection connection =null;
DBhelper helper = new DBhelper();
PreparedStatement statement = null;
ResultSet resultSet;
try{
connection= helper.getConnection();
System.out.println("baglantı olustu");
String sql = "INSERT INTO pandemi(toplamvirus) VALUES ('?') ";
statement = connection.prepareStatement(sql);
statement.setInt(1,2);
statement.executeUpdate(sql);
int result = statement.executeUpdate();
}
catch (SQLException exception){
helper.showErrorMessage(exception);
}
finally {
statement.close();
connection.close();
}
//String sql = "UPDATE pandemi SET toplamvirus='ff' ";
}
And the error is:
baglantı olustu
Error: Parameter index out of range (1 > number of parameters, which is 0).
Error code : 0
The database is: https://prnt.sc/rile7q