首页 > 其他 > 详细

CLOB,BLOB与String互转。

时间:2018-05-28 19:43:37      阅读:173      评论:0      收藏:0      [点我收藏+]

String s1="1231dsdgasd的飒飒大";

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()));

System.out.println(clobString);
System.out.println(blobString);

CLOB,BLOB与String互转。

原文:https://www.cnblogs.com/zhonwenchao/p/9101845.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!