Mysql
 sql >> Database >  >> RDS >> Mysql

Il modo più semplice per convertire un BLOB in una matrice di byte

la classe BLOB mySql ha la seguente funzione:

usalo in questo modo:

//(assuming you have a ResultSet named RS)
Blob blob = rs.getBlob("SomeDatabaseField");

int blobLength = (int) blob.length();  
byte[] blobAsBytes = blob.getBytes(1, blobLength);

//release the blob and free up memory. (since JDBC 4.0)
blob.free();