您的位置:首页 > 编程语言 > Java开发

基于Spring,CLOB/BLOB/String互转

2015-11-18 15:19 816 查看
String s1="Holle world!";

Clob c = new SerialClob(s1.toCharArray());//String 转 clob
Blob b = new SerialBlob(s1.getBytes("GBK"));//String 转 blob
//      也可以不传字符集名称,那么默认使用系统的
//      Blob b = new SerialBlob(s1.getBytes());

String clobString = c.getSubString(1, (int) c.length());//clob 转 String
String blobString = new String(b.getBytes(1, (int) b.length()),"GBK");//blob 转 String
//      前面若没传入字符集名称,则这里也不需要传入,以免出错
//      String blobString = new String(b.getBytes(1, (int) b.length()));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: