Berch Berch - 1 year ago 67
MySQL Question

Unable to UPDATE / REPLACE multiple stored Images in MySql

I have a MySql dB containing Images(BLOB) & Text data types, I'm able to Insert & Delete text & Images to and from Database, I'm unable to replace an existing image using the UPDATE query. Code executes without errors but not functional.Your help on this matter is greatly appreciated.

@FXML private void UpdateData(ActionEvent ae){
String sql= "UPDATE EMPLOYEE SET SLNO=?,NAME=?,DES=?,IMAGE1=?,IMAGE2=?,IMAGE3=? where SLNO='"+slnoField.getText()+"'";

pst.setString(1, slnoField.getText());
pst.setString(2, nameField.getText());
pst.setString(3, desField.getText());

fis1 = new FileInputStream(file1);
pst.setBinaryStream(4, (InputStream)fis1, (int)file1.length());

fis2 = new FileInputStream(file2);
pst.setBinaryStream(5, (InputStream)fis2, (int)file2.length());

fis3 = new FileInputStream(file3);
pst.setBinaryStream(6, (InputStream)fis3, (int)file3.length());

}catch(Exception e){

Answer Source

you are missing a prepared statement

pst = conn.prepareStatement(sql);

Go through this video, shows how to update an image in the Time frame of 6:04 to 10:00 minutes range:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download