首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Db2 数据库选定CLOB 里面的内容

2012-08-10 
Db2 数据库选出CLOB 里面的内容在db2 server上,用sql 语句选 clob 字段,果里面的数据很大,有3M 左右大小的

Db2 数据库选出CLOB 里面的内容
在db2 server上,用sql 语句选 clob 字段,果里面的数据很大,有3M 左右大小的内容,
直接选不出来。
方法一:
写个一个java 程序,选出的结果放到文件中。

package com.ibm;import java.io.*;import java.sql.*;public class TestConnDb2 {public static void main(String[] args) {try {Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();String url = "jdbc:DB2:oi9ods";String user = "youruser";String password = "yourpassword";Connection conn = DriverManager.getConnection(url, user, password);String sql = "select pricexml from price.wwprtxml where id = 34851 with ur";Statement stmt = conn.createStatement();ResultSet rs = stmt.executeQuery(sql);if (rs.next()) {System.out.println("test start");Writer output = null;String text = rs.getString(1);File file = new File("xml.txt");output = new BufferedWriter(new FileWriter(file));output.write(text);output.close();System.out.println("test end!");}conn.close();} catch (Exception e) {e.printStackTrace();}}}


方法二:
db2 connect to oi9ods user youruser using yourpassword
db2 export to wwprt.del of del modified by lobsinfile messages wwprt.msg select pricexml from price.wwprtxml where id = 34851 with ur

可是不知道为什么,用export 方法导出的文件的内容有问题,里面包含2遍 字段里面的内容,暂时还可以用,把重复的内容去掉,随后再仔细研究一下原因。

热点排行