日期:2014-05-18  浏览次数:20663 次

帮忙看一看这段代码,为什么不能够执行查询
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.0   Transitional//EN ">
<%@   page   contentType= "text/html;charset=UTF-8 "   %>
<%@   page   import= "java.sql.* "   %>
<html>
<head>
<title> select标签测试 </title>
</head>
<body>
<form   name= "form "   action= "select.jsp "   method= "get ">
<select   name= "n1 "   size= "1 "   onchange= "optt.value=this.options[this.selectedIndex].name ">
<option   value=5> </option>
<option   name= "id "   value=1> 记录编号 </option>
<option   name= "name "   value=2> 姓名 </option>
<option   name= "age "   value=3> 年龄 </option>
<option   name= "sex "   value=4> 性别 </option>
</select>
<input   type= "text "   name= "user ">
<input   name= "optt "   type= "text "   value= " ">
<input   type= "submit "   name= "submit "   value= "search ">

<table   width= "100% ">
    <tr>
        <td   width= "10% "   bgcolor= "gray "> 记录编号 </td>
        <td   width= "10% "   bgcolor= "gray "> 姓名 </td>
        <td   width= "10% "   bgcolor= "gray "> 年龄 </td>
        <td   width= "10% "   bgcolor= "gray "> 性别 </td>
        <td   width= "30% "   bgcolor= "gray "> 电子邮箱 </td>
        <td   width= "30% "   bgcolor= "gray "> 地址 </td>
    </tr>
    </table>
<%!
String   s1=null;
String   s2=null;
String   s3=null;
%>
<%   Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
    String   url   =   "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=motivecall ";
    String   user   =   "sa ";
    String   passwd   =   "123456 ";
    Connection   conn   =   DriverManager.getConnection(url,user,passwd);
    Statement   stmt   =   conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    String   s1=(String)request.getParameter( "n1 ");
    String   s2=(String)request.getParameter( "user ");
    String   s3=(String)request.getParameter( "optt ");
    String   sql= "select   *   from   james_user   where   ' "+s3+ " '   like '% "+s2+ "% ' ";
    ResultSet   rs   =   stmt.executeQuery(sql);
    while(rs.next())   {   %>
    <table   width= "100% ">