Código:
Agradezco su apoyo. PreparedStatement pst3 = null;
String Fn = Ficha.getText();
Connection conn2 ;
conn2 = javaconnect.ConnecrDb();
String sqlf = "SELECT * FROM Empleados WHERE Ficha = ?";
if (Fn.isEmpty() == true) {
JOptionPane.showMessageDialog(this, "No se puede consultar un valor que no ha sido ingresado verifique ficha.", "ERROR.", JOptionPane.ERROR_MESSAGE);
} else {
try {
pst3 = conn2.prepareStatement(sqlf);
pst3.setString(1, Fn);
resultado = pst3.executeQuery();
if (resultado.next()) {
Nombre.setText(resultado.getString("Nombre"));
Apellido_paterno.setText(resultado.getString("Apellido_paterno"));
Apellido_materno.setText(resultado.getString("Apellido_materno"));
Vigencia.setDate(resultado.getDate("Vigencia"));
Directo.setText(resultado.getString("Directo"));
Extension.setText(resultado.getString("Extension"));
Observaciones.setText(resultado.getString("Observaciones"));
if (resultado.getBinaryStream("Firma") == null) {//si no encuentra la imagen
JOptionPane.showMessageDialog(this, "No image");
} else {
//int len = resultado.getInt("Tamano");
byte[] b = new byte[1024];//array de bytes
InputStream in = resultado.getBinaryStream("Firma");
int n = in.read(b);
in.close();
Image img = Toolkit.getDefaultToolkit().createImage(b);
resultado.close();
conn.close();
Firma.setIcon((Icon) img);
}
} else {
JOptionPane.showMessageDialog(this, "La ficha no esta registrada, verifique o intente registrar.", "Error", JOptionPane.ERROR_MESSAGE);
}
} catch (SQLException | HeadlessException | IOException ex) {
System.out.println(ex);
JOptionPane.showMessageDialog (this, ex);
}
}


Este tema le ha gustado a 1 personas