I'm using a mysql database, just like I'm using JavaFx with the Scene Builder.
My problem is that I have saved an image in a database and when I try to access it to insert it in an ImageView, I get an error:
ERROR: "incompatible types: bufferedimage can not be converted to image"
This is the code:
ConexionBD con = new ConexionBD();
Connection cn = con.Conexion();
Statement prep2;
ResultSet result2;
String consulta2 = "SELECT Nombre,Logo FROM datosempresa";
try {
prep2 = cn.createStatement();
result2 = prep2.executeQuery(consulta2);
if (result2.next()) {
lblNombreEmpresa.setText(result2.getString(1)); //Funciona
Image i = null;
Blob blob = result2.getBlob("Logo");
i = javax.imageio.ImageIO.read(blob.getBinaryStream()); //ERROR!
imgFotoEmpresa.setImage(i); //imgFotoEmpresa = ImageView
}
} catch (SQLException ex) {
Logger.getLogger(PrincipalController.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex.getMessage());
}