<%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <% Class.forName ("org.gjt.mm.mysql.Driver").newInstance(); String url ="jdbc:mysql://localhost/com?user=root&password=nafio&useUnicode=true&characterEncoding=UTF-8"; Connection conn= DriverManager.getConnection(url); Statement stmt=conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); %> <% String nameP = (String)request.getParameter("name"); String passP = (String)request.getParameter("pass"); %> <html> <head> <title> Title </title> </head> <body> <% String num = ""; String sql = "select * from gua where name=""+nameP+"""; ResultSet rs=stmt.executeQuery(sql); if(rs.next())num=rs.getString(4); rs.close(); %> 测试:<%=sql %> 用户名:<%=nameP %> 密码: <%=passP %> 查询结果:<%=num %> </body> </html>