I'm trying to remove a data from the database, but the following error occurs:
Parameter index out of range (1 > number of parameters, which is 0)
Can you help me?
public void remove(Bean e) {
try {
PreparedStatement stmt = ConexaoMysql.getConexao()
.prepareStatement("DELETE FROM coluna WHERE id = 5");
stmt.setInt(1,e.getId());
stmt.execute();
stmt.close();
System.out.println("Removido!");
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
public class TesteRemover {
public static void main(String[] args) {
Bean p = new Bean ();
Dao dao = new Dao ();
p.setIdexemplo(5);
dao.remove(p);
}
}