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


i'am getting problem whene execute upadate query , problem whene wante update blob column im sqlite table, notice path blob file stored. whene use insert query binding value :pst.setbinarystream(file); works fine!

i blob file 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 update query :

  int aderentid =100;    string updateaderent=" update gss_aderent set"                         + "ad_photo='"+image+"'                         + "where ad_id='"+aderentid+"' ";   stmt.executeupdate(updateaderent); 

my problem : updated value isn't blob value path:( question how store(update) blob value in update query ? exist method bind binarystream parametre update query ? can use preparedstatement in update query ?

your application looks it's open sql injection attacks

use preparedstatement , setblob(int x, inputstream in)


Comments