<% @ Page contenttype = "text/html; charset = gb2312" %>
<% @ Page Language = "Java" %>
<% @ Page info = "Database handler" %>
<% @ Page import = "Java. Io. *" %>
<% @ Page import = "Java. Lang. *" %>
<% @ Page import = "Java. util. *" %>
<% @ Page import = "Java. SQL. *" %>
<% @ Page import = "javax. servlet. *" %>
<% @ Page import = "javax. servlet. http. *" %>
<HTML>
<Head>
<Meta content = "text/html; charset = gb2312" http-equiv = "Content-Type">
</Head>
<Body>
<%
Int I = 0;
String temp = NULL;
String parcode = request. getparameter ("Code ");
String strsql;
Try {
Connection con;
Statement stmt;
Resultset RS;
Class. forname ("Sun. JDBC. ODBC. jdbcodbcdriver ");
String url = "JDBC: oracle: thin: @ 192.168.15.248: 1521: ycdb ";
Con = drivermanager. getconnection (URL, "webcfcquery", "kill859 ");
// Out. println ("<center> JDBC connection to the Oracle database </center> <br> ");
Stmt = con. createstatement ();
Strsql = "select account_holder, description from account_holder ";
If (parcode! = NULL)
Strsql + = "where account_holder =" + parcode + "";
Rs1_stmt.exe cutequery (strsql );
Fileoutputstream fo = new fileoutputstream ("/usr/local/tomcat/webapps/vehicles/treasurer_voucher.xml ");
Printstream so = new printstream (FO );
While (Rs. Next ()){
String col1 = Rs. getstring (1 );
String col2 = Rs. getstring (2 );
Try {
If (I = 0 ){
So. println ("<? XML version =/"1.0/" encoding =/"gb2312/"?> ");
So. println ("<ufinterface roottag =/" voucher/"billtype =/" Gl/"subtype =/"/"replace =/" Y/"receiver =/" 1051/"sender =/"1101/" isexchange =/"Y/" filename =/"Accounting credential. XML/"> ");
So. println ("<voucher id =/" 1234560102/"> ");
// Note: An error is reported when the XML file is displayed. Why? So. println ("<custcode>" + col1 + "</custcode> ");
So. Print ("<custcode> ");
If (col2 = NULL) {// if you do not judge whether the object col2 is null, an nullpointerexception exception may occur during encoding conversion.
So. Print (col2 );
} Else {// because the encoding display mode of the XML file has been defined earlier is gb2312, You need to convert the string col2 to gb2312 before writing it into XML, in this way, Chinese characters can be normally displayed in the XML file.
Byte [] temp_col = col2.getbytes ("gb2312 ");
Col2 = new string (temp_col );
So. Print (col2 );
}
So. println ("</custcode> ");
}
} Catch (exception e ){
Out. println (E. tostring ());
}
I ++;
}
So. println ("</voucher> ");
So. println ("</ufinterface> ");
So. Close ();
} Catch (exception e ){
Out. println (E );
}
%>
</Body>
</Html>
Article arrangement:Webmaster skyURL: http://www.z6688.com/