Hehe, you want to get all codes by only 20 points?

解决方案 »

  1.   

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

  2.   

    CAYU(中原) :我要的不是从数据库是提取数据放到xml中,而是直接把form表单提交上来的数据存在xml中。
      

  3.   

    request.getParameter("xxx")得到参数,然后就写成xml形式的文件就可以了吧!