jsp讀取大對(duì)象CLOB并生成xml文件示例
更新時(shí)間:2006年10月13日 00:00:00 作者:
<%@ 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);
//將從數(shù)據(jù)庫(kù)中讀出的內(nèi)容寫(xiě)到文件中
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>
您可能感興趣的文章:
- JS解析XML文件和XML字符串詳解
- JS讀取XML文件示例代碼
- JS操作XML實(shí)例總結(jié)(加載與解析XML文件、字符串)
- JS與jQ讀取xml文件的方法
- JavaScript操作XML文件之XML讀取方法
- JS使用ajax從xml文件動(dòng)態(tài)獲取數(shù)據(jù)顯示的方法
- javascript讀取Xml文件做一個(gè)二級(jí)聯(lián)動(dòng)菜單示例
- IE下JS讀取xml文件示例代碼
- 用javascript讀取xml文件讀取節(jié)點(diǎn)數(shù)據(jù)
- javascript實(shí)現(xiàn)加載xml文件的方法
- 使用JS讀取XML文件的方法
- jQuery解析XML文件同時(shí)動(dòng)態(tài)增加js文件的方法
- JS實(shí)現(xiàn)加載和讀取XML文件的方法詳解
相關(guān)文章
web前端超出兩行用省略號(hào)表示的實(shí)現(xiàn)方法
這篇文章主要介紹了web前端超出兩行用省略號(hào)表示的實(shí)現(xiàn)方法的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-10-10Struts2中實(shí)現(xiàn)web應(yīng)用的初始化實(shí)例詳解
這篇文章主要介紹了Struts2中實(shí)現(xiàn)web應(yīng)用的初始化實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-06-06Struts1之url截取_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
這篇文章主要介紹了Struts1之url截取_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理的相關(guān)資料,需要的朋友可以參考下2017-09-09點(diǎn)擊地圖div上的按鈕實(shí)現(xiàn)對(duì)地圖數(shù)據(jù)的入庫(kù)操作
在地圖div上添加一個(gè)按鈕并單擊在彈出層的輸入框內(nèi)輸入數(shù)據(jù)后點(diǎn)擊提交按鈕將數(shù)據(jù)提交至數(shù)據(jù)庫(kù),具體的實(shí)現(xiàn)如下,感興趣的朋友可以參考下2013-08-08