<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ page import="java.sql.*" %>
My JSP starting page <%
String select=request.getParameter("select");
String sql=null;
out.print(select);
try{Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
Class.forName("com.mysql.jdbc.Driver");
con =DriverManager.getConnection("jdbc:mysql://localhost:3306/login?useUnicode=true&characterEncoding=GBK","root","123456");
sql="select * from apply where caiwuyijian=?";
ps=con.prepareStatement(sql);
ps.setString(1,select);
rs=ps.executeQuery();
while(rs.next()){
out.print(rs.getString("Id")+"--");
out.print(rs.getString("name")+"--");
out.print(rs.getString("price")+"--");
out.print(rs.getString("reason")+"--");
out.print(rs.getString("applyer")+"--");
out.print(rs.getString("time")+"--");
}
rs.close();
ps.close();
con.close();}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
我这个作用是 在页面输入查询条件 然后调用数据库显示在页面上 看看有帮助么