简体   繁体   中英

how to Convert String to byte array and byte array to Blob using only java program

Question is:

String strContent = "Hello Hi How are you ";
byte[] byteConent = strContent.getBytes();

But further I want convert to Blob only in Java program

Because I m working on some script for MySQL DB by default for our application.

Regards, Satish

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

Where connection is the connection to db object.

Blob blob=null; 
blob=new SerialBlob(byteContent);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM