vendredi 10 juillet 2015

JavaFX,SQLite : How to Set BLOB Value in update Query?

I'am getting a problem whene i execute upadate query , the problem is whene i wante to update the blob column im my sqlite table, i notice that only the path this blob file are stored. but whene is use insert query with binding value like that :pst.setBinaryStream(File); it works fine!

I get my blob file with this code :

File image=null;
URL photoURL = null;
try {
    photoURL = new URL(addadh_adherent_photo_label.getText());
} catch (MalformedURLException ex) {
    Logger.getLogger(ParametresController.class.getName()).log(Level.SEVERE, null, ex);
}

try {
    image= new File( URLDecoder.decode( photoURL.getFile(), "UTF-8" ) );
} catch (UnsupportedEncodingException ex) {
    Logger.getLogger(ParametresController.class.getName()).log(Level.SEVERE, null, ex);
} 
FileInputStream   fis = null;
try {
    fis = new FileInputStream(image);
} catch (FileNotFoundException ex) {
    Logger.getLogger(ParametresController.class.getName()).log(Level.SEVERE, null, ex);
}

and here is my update query :

  int AderentId =100; 
  String updateAderent=" UPDATE gss_aderent SET"
                        + "ad_photo='"+image+"'
                        + "WHERE ad_id='"+AderentId+"' ";
  stmt.executeUpdate(updateAderent);

My problem is : The updated value isn't a blob value but just his path:( my question is how to store(update) blob value in update query ? does exist a method to bind BinaryStream parametre for update query ? can i use preparedStatement in update query ?

Aucun commentaire:

Enregistrer un commentaire