<% @ 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 ();
// Use stream to read CLOB or BLOB Columns
StrSql = "select xmlgen. getxml ('select * from account_holder where id_no = ''000000') from dual ";
ResultSet rs1_stmt.exe cuteQuery (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 );
// Write the content read from the database to the file
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>