Easiest way to convert byte array into Blob in jav

2019-01-14 18:48发布

问题:

What is the easiest way to convert byte array into Blob data type in MYSQL with java programming language?

回答1:

Blob blob = connection.createBlob();
blob.setBytes(1, bytes);


回答2:

You may try this one, if you are using hibernate.. Possibly the easiest way! :)

Blob blob = Hibernate.createBlob(bytes);


回答3:

Blob fileBlob = new javax.sql.rowset.serial.SerialBlob(byteArray);