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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -