Clob类型转换成String类型
来源:互联网 发布:软件版本 编辑:程序博客网 时间:2024/05/02 04:43
oracle中表结构如下:
create table GRID_RESOURCE( ID VARCHAR2(50), CNNAME VARCHAR2(50), TYPE VARCHAR2(50), PARENTID VARCHAR2(50), VIEWWIDTH VARCHAR2(50), REQUESTURL VARCHAR2(256), COUNTSQL CLOB, ISDISPLAY VARCHAR2(50), TREEINDEX VARCHAR2(256), TABLES VARCHAR2(256), NOTE3 VARCHAR2(256))COUNTSQL字段为CLOB类型,索引为6
import java.io.BufferedReader;import java.io.IOException;import java.io.Reader;import java.sql.Clob;import java.sql.SQLException;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import org.hibernate.SessionFactory;import org.hibernate.cfg.Configuration;public class T {public static final SessionFactory sessionFactory;static {try {sessionFactory = new Configuration().configure().buildSessionFactory();} catch (Throwable ex) {throw new ExceptionInInitializerError(ex);}}/** * @param args */public static void main(String[] args) {new T().getList();}public void getList() {String querySQL = "select * from GRID_RESOURCE";String countSQL = "";List<Object[]> list = new ArrayList<Object[]>();// List o_list = new ArrayList();try {list = sessionFactory.openSession().createSQLQuery(querySQL).list();for (Object[] obj : list) {Map<String, Object> map = new HashMap<String, Object>();Clob sc = (Clob) obj[6];countSQL = ClobToString(sc);System.out.println(countSQL);}// 另一个遍历方法/* * for(Object obj:o_list){ Object oo[] = (Object[])obj; * System.out.println(oo[6]); } */} catch (Exception e) {e.printStackTrace();}}// 将字Clob转成String类型public String ClobToString(Clob sc) throws SQLException, IOException {String reString = "";Reader is = sc.getCharacterStream();// 得到流BufferedReader br = new BufferedReader(is);String s = br.readLine();StringBuffer sb = new StringBuffer();while (s != null) {// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRINGsb.append(s);s = br.readLine();}reString = sb.toString();return reString;}}
2 0
- Clob转换成String类型
- Clob类型转换成String类型
- Clob类型转换成String类型
- Blob,Clob类型转换String
- Oracle中的Clob与String类型转换
- Oracle中的Clob与String类型转换
- clob类型转换为string类型的orcal函数
- Clob类型与String类型的相互转换
- Clob类型与String类型的相互转换
- clob类型转String类型
- clob转化String类型
- 将数据库中Clob类型转换成java的String类型
- Oracle 中Clob 字段,转换为 String 类型
- Oracle中Clob类型的字段数据转换成String字符串
- 数据库Clob类型转String类型
- 数据库Clob类型转String类型
- String类型如何转CLOB 类型
- Java Clob类型转String类型
- 排序(1)--插入排序和交换排序
- Java中获取键盘输入值的三种方法
- 工厂方法
- TP-LINK tl-wr845n路由器的桥接设置:
- 将笔记本设置为wifi热点
- Clob类型转换成String类型
- Cracking the coding interview--Q8.1
- svn 冲突原因及解决方法
- 均匀试验设计表格的问题
- R树空间索引
- Ubuntu 12.04 分区方案(仅供参考)
- 正则表达式用法大全
- AD一些常用指令
- eclipse pydev 装不上的原因 安装错误