展开全部
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP starting page</title>
</head>
<body> <form method="post">
请输入查询单号:<input type="text" maxlength="20" size="10" name="select"><input value="提交" type="submit" name="button1">
</form></body>
<%
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());
}
%>
</html>
我这个作用是 在页面输入查询条件 然后调用数据库显示在页面上 看看有帮助么
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP starting page</title>
</head>
<body> <form method="post">
请输入查询单号:<input type="text" maxlength="20" size="10" name="select"><input value="提交" type="submit" name="button1">
</form></body>
<%
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());
}
%>
</html>
我这个作用是 在页面输入查询条件 然后调用数据库显示在页面上 看看有帮助么
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
一楼的正解
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询