import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class servlet1 extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html; charset=GBK"); // 设置响应属性
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException ex)
{
}
try
{
String URL = "jdbc

dbc:dbf";
Connection con = DriverManager.getConnection(URL);
Statement stmt = con.createStatement();
InputStream is = request.getInputStream();
DataInputStream dis = new DataInputStream(is);
String readStr1 = dis.readUTF(); // 读入第一个参数
String SQL = "SELECT * FROM HHQ WHERE HQ=" + "'" + readStr1+ "'";
ResultSet rs = stmt.executeQuery(SQL);
DataOutputStream dos = new DataOutputStrem(response.getOutputStream());
while (rs.next())
{
dos.writeUTF(rs.getString("HQ1")+"\n");
dos.writeUTF(rs.getString("HQ2")+"\n");
dos.writeUTF(rs.getDouble("HQ3")+"\n");
dos.writeUTF(rs.getDouble("HQ4")+"\n");
dos.writeUTF(rs.getDouble("HQ5")+"\n");
break;
}
rs.close();
dis.close();
dos.close();
stmt.close();
con.close();
} catch (SQLException ex)
{
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
}
public void destroy()
{
}
// 清除资源
}
[
本帖最后由 supergo 于 2008-5-12 01:52 PM 编辑 ]