JSP模糊查询的问题
更多更新更免费论文网,专业毕业设计论文,课程设计源代码,上机实习报告,实验报告请点击www.751com.cn
<%
String username=request.getParameter("cx");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String strurl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\db.mdb";
Connection con=DriverManager.getConnection(strurl,"","") ;
Statement stmt=con.createStatement();
String sql="select * from user where username like '%"+username+"%' ";
ResultSet rs=stmt.executeQuery(sql);
%>
<%
while(rs.next()){
out.println("查询结果∶<br/>");
out.println("--------------<br/>");
out.println(rs.getString(1));
out.println(rs.getString(2));
out.println(rs.getString(3));
}
else
{
out.println("查询结果∶<br/>");
out.println("--------------<br/>");
out.println("<font color=red>"+"没有符合条件的记录。。。"+"</font>");
}
rs.close();
con.close();
stmt.close();
%>
<body>
<form action="cangkuchanpingmingcheng.jsp" method="post">
<label>按产品名称:</label>
<input name="parm1" value=""></input>
<input type=submit name="Submit4" value="提交">
<input type="reset" name="Submit3" value="清空">
</form>
</body>