sqlite - byte [] to blob conversion in java using preparedstatement and sqllite -
i trying convert byte [] blob. code follows
byte [] hashvalue = hashclass.hash256bytes(messagevalue); //query = "insert message values (?)"; connection = connectionfactory.getconnection(); //blob blob = new javax.sql.rowset.serial.serialblob(hashvalue); blob blob = new serialblob(hashvalue); //blob.setbytes(1, hashvalue); prestatement = (preparedstatement) connection.preparestatement(query); prestatement. setblob(1, blob); rs = prestatement.executequery();
but breaking @ prestatement. setblob(4, blob). have did bit google , tried below code give null @ connection.createblob().
blob blob = connection.createblob(); blob.setbytes(1, bytes);
try setbytes();
method
byte [] hashvalue = hashclass.hash256bytes(messagevalue); //query = "insert message values (?)"; connection = connectionfactory.getconnection(); //blob blob = new javax.sql.rowset.serial.serialblob(hashvalue); //blob blob = new serialblob(hashvalue); prestatement = (preparedstatement) connection.preparestatement(query); prestatement. setbytes(1, hashvalue); rs = prestatement.executequery();
Comments
Post a Comment