谁能给一个jsp+xml+css的简单小例子? Hehe, you want to get all codes by only 20 points? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 package jdbcsql;import java.sql.*;import java.util.Properties;import java.io.*;/** * Title: JDBC Sample to Access SQL Server * Description: Accesses the FOR XML functionality of * SQL Server and builds the resultset. * Copyright: Copyright (c) 2001 * Company: Gone West Systems * @author Rich Rollman * @version 1.0 */public class JDBCSQL{ public static void main(java.lang.String[] args) { queryODBCBridge(); } private static void queryODBCBridge() { try { // Load the driver and establish a connection. Driver myDriver = (Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:odbc:sqlnorthwind","sa",""); // Create and execute an SQL statement. Statement stmt = conn.createStatement(); stmt.execute("select * from Customers as Customer order by CompanyName for xml auto"); ResultSet rs = stmt.getResultSet(); // Open a buffered writer on a file for output. BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("ODBCResults.xml"))); bw.write("<?xml version='1.0' encoding='windows-1252' ?><root>"); int c; // Display the SQL results. while(rs.next()) { InputStream is = rs.getBinaryStream(1); InputStreamReader isr = new InputStreamReader(is,"UnicodeLittle"); while ((c = isr.read()) != -1) { bw.write(c); } } bw.write("</root>"); bw.close(); // Release database resources. rs.close(); stmt.close(); conn.close(); } catch (ClassNotFoundException cnfe) { System.out.println("Unable to load Driver Class: " + cnfe.getMessage()); cnfe.printStackTrace(System.out); return; } catch (SQLException se) { // Inform user of any SQL errors. System.out.println("SQL Exception: " + se.getMessage()); se.printStackTrace(System.out); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(System.out); } }} CAYU(中原) :我要的不是从数据库是提取数据放到xml中,而是直接把form表单提交上来的数据存在xml中。 request.getParameter("xxx")得到参数,然后就写成xml形式的文件就可以了吧! 100分看看一段关于struts的验证的代码 java ejb加了一个service层后在web层调用sessionBean报空指针 欢迎有志之士加入JAVA技术群......... 关于服务器的问题请大侠帮忙 我编写了一个简单的servlet报错. 为什么我的tomcat老是启动不起来啊?高手帮忙 MySQL,JDBC的数据显示的问题 关于客户端数字认证问题 我也了一个ejb,出现了这个错误,请教! 求大佬看一下这个Tomcat启动不了是什么问题,谢谢! 谁知道WebGain在哪有下载 如何返回一个xml串,急!(格式如下)
import java.util.Properties;
import java.io.*;/**
* Title: JDBC Sample to Access SQL Server
* Description: Accesses the FOR XML functionality of
* SQL Server and builds the resultset.
* Copyright: Copyright (c) 2001
* Company: Gone West Systems
* @author Rich Rollman
* @version 1.0
*/public class JDBCSQL
{
public static void main(java.lang.String[] args)
{
queryODBCBridge();
} private static void queryODBCBridge()
{
try
{
// Load the driver and establish a connection.
Driver myDriver = (Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:odbc:sqlnorthwind","sa",""); // Create and execute an SQL statement.
Statement stmt = conn.createStatement();
stmt.execute("select * from Customers as Customer order by CompanyName for xml auto");
ResultSet rs = stmt.getResultSet(); // Open a buffered writer on a file for output.
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new
FileOutputStream("ODBCResults.xml"))); bw.write("<?xml version='1.0' encoding='windows-1252' ?><root>"); int c; // Display the SQL results.
while(rs.next())
{
InputStream is = rs.getBinaryStream(1);
InputStreamReader isr = new InputStreamReader(is,"UnicodeLittle"); while ((c = isr.read()) != -1)
{
bw.write(c);
}
} bw.write("</root>"); bw.close(); // Release database resources.
rs.close();
stmt.close();
conn.close();
}
catch (ClassNotFoundException cnfe)
{
System.out.println("Unable to load Driver Class: " + cnfe.getMessage());
cnfe.printStackTrace(System.out);
return;
}
catch (SQLException se) {
// Inform user of any SQL errors.
System.out.println("SQL Exception: " + se.getMessage());
se.printStackTrace(System.out);
}
catch (Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace(System.out);
}
}
}