jsp读取大对象CLOB并生成xml文件示例(转)


















int i=0;
String parID = request.getParameter("id_no");
String strSql;
String content="";

try{
String xmlFile = "/usr/local/tomcat/webapps/vehicles/test.xml";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dburl="jdbc:oracle:thin:@192.168.15.250:1521:ycdb";
Connection con=DriverManager.getConnection(dburl,"training","deep1704sea");
Statement stmt=con.createStatement();

//使用流读取CLOB或BLOB列
strSql = "select xmlgen.getxml('select * from account_holder where id_no=''0001''') from dual ";
ResultSet rs=stmt.executeQuery(strSql);
if(rs.next()){
CLOB clob = ((OracleResultSet)rs).getCLOB(1);
if(clob!=null){
Reader is = clob.getCharacterStream();
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
while(s!=null){
//byte[] temp = s.getBytes("iso-8859-1");
//s = new String(temp);
content += s;
s=br.readLine();
}
}
}
//out.println(content);

//将从数据库中读出的内容写到文件中
FileOutputStream fo = new FileOutputStream(xmlFile);
PrintStream so = new PrintStream(fo);
so.println(content);
so.close();

rs.close();
stmt.close();
con.close();

}catch(Exception e){
out.println(e);
}
%>


[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9650775/viewspace-922501/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9650775/viewspace-922501/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值