Hello everyone I am new to programming, I have a problem, my system connects to mysql
and uploads data to the database, but I miss an error when trying to delete, I hope you can help me because I do not I see the error.
private void eliminarActionPerformed(java.awt.event.ActionEvent evt) {
int fila = tabladatos.getSelectedRow();
String valor = tabladatos.getValueAt(fila, 0).toString();
String sql = "DELETE FROM clientes WHERE Id_cliente = ?";
if (fila >= 0) {
try {
PreparedStatement ps = cn.prepareStatement(sql + (valor));
ps.setString(1, id.getText());
ps.setString(2, nombre.getText());
ps.setString(3, domicilio.getText());
ps.setString(4, telefono.getText());
ps.executeUpdate();
mostrartabla();
JOptionPane.showMessageDialog(null, "Datos eliminados");
} catch (SQLException e) {
System.out.println(e);
}
}
}
The error that marks me is this:
java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1)