欢迎光临
我们一直在努力

jsp读取大对象CLOB并生成xml文件示例-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

<%@ page contenttype="text/html; charset=gb2312" %>

<%@ page info="database handler"%>

<%@ page import="java.io.*"%>

<%@ page import="java.net.*"%>

<%@ page import="java.lang.*"%>

<%@ page import="java.util.*"%>

<%@ page import="java.sql.*"%>

<%@ page import="javax.servlet.*"%>

<%@ page import="javax.servlet.http.*"%>

<%@ page import="oracle.sql.clob"%>

<%@ page import="oracle.jdbc.driver.oracleresultset"%>

<html>

<head>

<meta content="text/html; charset=gb2312" http-equiv="content-type">

</head>

<body>

<%

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

}

%>

</body>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » jsp读取大对象CLOB并生成xml文件示例-JSP教程,Jsp/Servlet
分享到: 更多 (0)