Java如何读取CLOB字段
CLOB字段是Oracle用来存储大容量内容的字段类型,CLOB字段可以存储最高4G的容量。
Java读取CLOB和读取普通类型字段有一点不一样,以下代码实现了如何读取CLOB字段:
connection.setAutoCommit(false);
PreparedStatement preparedStatement=connection.prepareStatement(sql);
ResultSet rs=preparedStatement.executeQuery();
Clob clob=rs.getClob(colName);
if(clob!=null)
{
Reader reader=((oracle.sql.CLOB)clob).getCharacterStream();
BufferedReader br=new BufferedReader(reader);
String value=”";
String line=”";
while((line=br.readLine())!=null)
{
value+=line+”\r\n“;
}
}
rs.close();
preparedStatement.close();
其中value就是java读取的CLOB字段的值。
Java读取CLOB和读取普通类型字段有一点不一样,以下代码实现了如何读取CLOB字段:
connection.setAutoCommit(false);
PreparedStatement preparedStatement=connection.prepareStatement(sql);
ResultSet rs=preparedStatement.executeQuery();
Clob clob=rs.getClob(colName);
if(clob!=null)
{
Reader reader=((oracle.sql.CLOB)clob).getCharacterStream();
BufferedReader br=new BufferedReader(reader);
String value=”";
String line=”";
while((line=br.readLine())!=null)
{
value+=line+”\r\n“;
}
}
rs.close();
preparedStatement.close();
其中value就是java读取的CLOB字段的值。
【Java如何读取CLOB字段】相关文章
2. 若通过ObjectOutputStream向一个文件中多次以追加方式写入object,为什么用ObjectInputStream读取这些object时会产生StreamCorruptedExcepti
3. 软件测试LoadRunner面试题:What is the difference between standard log and extended log?
4. 软件测试LoadRunner面试题:If web server, database and Network are all fine where could be the problem?
8. C#里面如何判断一个Object是否是某种类型(如Boolean)?
9. 简述synchronized和java.util.concurrent.locks.Lock的异同
本文来源:https://www.mianshiwenti.com/a12459.html
进入下载页面
上一篇:中科前程Java笔试题
下一篇:值传递还是引用传递
﹝Java如何读取CLOB字段﹞相关内容
- Overload和Override的区别。Overloaded的方法是否可以改变返回值的类型
- 软件测试LoadRunner面试题:How did you plan the Load? What are the Criteria?
- 软件测试LoadRunner面试题:Explain the following functions: – lr_debug_message
- 简单介绍Object类的功能、常用方法
- 您熟悉ORM(Object-Relation Mapping)吗?请谈谈您所理解的ORM
- String s = new String(“xyz”);创建了几个String Object?
- 写clone()方法时,通常都有一行代码,是什么?
- System.Array.CopyTo()和System.Array.Clone()有什么区别
- Static Nested Class 和 Inner Class的不同
- 什么叫应用程序域?什么是托管代码?什么是强类型系统?什么是装箱和拆箱?什么是重载?CTS、CLS和CLR分别作何解释?