java - inserting byte array into blob column -
i'm trying insert byte array blob column in sqlite database. i've tried both setbinarystream , setbytes, i'm getting not implemented sqlite jdbc driver exception. i'm using sqlite-jdbc-3.8.7.jar.what jar should use work? thanks!
here's code:
public void adddriverdata(string prenume,string nume,string telefon,string email,string permis,string parola,byte[] photo) throws sqlexception { string sql = "insert driver(first_name,last_name,phone,email,permit,password,photo)values(?,?,?,?,?,?,?)"; preparedstatement stm = c.preparestatement(sql); stm.setstring(1,prenume); stm.setstring(2,nume); stm.setstring(3,telefon); stm.setstring(4,email); stm.setstring(5,permis); stm.setstring(6, parola); //stm.setbinarystream(7,new bytearrayinputstream(photo),photo.length); stm.setbytes(7, photo); system.out.println(sql); stm.executeupdate(sql); stm.close(); c.commit(); }
once preparedstatement
object has been created with
string sql = "insert ..."; preparedstatement stm = c.preparestatement(sql);
the object has processed sql
command text. when time comes execute preparedstatement need is
stm.executeupdate();
(the method call executeupdate(sql)
intended used statement
objects, not preparedstatement
objects.)
Comments
Post a Comment