Good who could help me to show data from a textfield I have this code and nothing that works for me.
Method to verify client
public int existeCliente(String cliente) {
// llamamos a la conexion bd
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = getConexionTemporal();
// Preparamos la consulta
String sql = "SELECT count(id_cliente) FROM cliente WHERE
cli_cedula=?";
try {
// Traemos los datos de la bd
ps = con.prepareStatement(sql);
ps.setString(1, cliente);
rs = ps.executeQuery();
// Cargamos los resultados
if (rs.next()) {
return rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
cerrarObjeto(con);
cerrarObjeto(rs);
cerrarObjeto(ps);
}
return 1;
}
and in the controller this I have // Client search method
@FXML
void buscarCliente(ActionEvent event) {
SqlFacturar cliente = new SqlFacturar();
// Validamos los campos que no esten vacios
if (txt_cedula.getText().equals("")) {
// validamos campos
Validaciones.checkEmptyFields(txt_cedula);
}else{
if (cliente.existeCliente(txt_cedula.getText())==0) {
JOptionPane.showMessageDialog (null, "Client does not exist, you must register it!");
}else{
txt_nombre.setText(cli.getNombre());
}
}
}
Thank you very much for helping me.