(菜鸟求救,在线关注)查询系统:使用JSP,HTML ,Access2003 怎么连接 具体程序如下

dybc1587 2006-03-10 04:45:03
先建一个数据库(std.mdb):其中有两个表 1.pw(密码表) 2.score成绩表
然后建两个Jsp文件

enter.jsp(登录页面,用来验正身份的)
-----------------------------------------------
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<title>个人成绩查询登录</title>
<body>
<center>
<font color=blue size=4><b><i>
请输入你的学号和密码</b></i>
</font>
<hr>
<form action="result.jsp" method="post">
<table border="1">
<tr><th bgcolor="yellow">学号</th><td>
<input type="text" size=10 name="number"></td></tr>
<tr><th bgcolor="yellow">密码</th><td>
<input type="password" size=10 name="password"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" vaule="查询"></td></tr>
</table>
</form>
<font color="red">
<%
String error=request.getParameter("errortype");
if(error!=null)
{
int errortype;
errortype=Integer.parseInt(error);
switch(errortype)
{
case 1:out.println("请输入学号!");break;
case 2:out.println("请输入密码!");break;
case 3:out.println("搞错,没有此人!");break;
case 4:out.println("密码错误!");break;
default:
}
}
%>
</font>
</body>
</html>



result.jsp(执行查询结果)
--------------------------------------------
<html>
<title>查询结果</title>
<body>
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*" %>
<%
String num=request.getParameter("number");
String password=request.getParameter("password");
int errortype=0;
if(num.equals(""))
{
errortype=1;
response.sendRedirect("enter.jsp?errortype="+errortype);
}
else if(password.equals(""))
{
errortype=2;
response.sendRedirect("enter.jsp?errortype="+errortype);
}
else
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:odbc:std");
Statement smt=con.createStatement();
String sql="select * from pw where 学号=´"+num+"´";
ResultSet rs=smt.executeQuery(sql);
if(!rs.next())
{
errortype=3;
response.sendRedirect("enter.jsp?errortype="+errortype);
}
else if(!rs.getString(2).equals(password))
{
errortype=4;
response.sendRedirect("enter.jsp?errortype="+errortype);
}
else
{

sql="select * from score where 学号=´"+num+"´";
rs=smt.executeQuery(sql);
rs.next();
out.println(rs.getString(1)+",你好,你的成绩如下:"+"<hr>");
out.println("<table border=´1´>");
out.println("<tr bgcolor=´gray´><th>姓名</th><th>专业英语</th><th>软件工程</th><th>C程序设计</th><th>Java程序设计</th><th>数据库原理</th><th>计算机网络</th></tr>");
out.println("<tr><td>"+rs.getString(2)+"</td><td>"+rs.getString(3)+"</td></td>"+"</td><td>"+rs.getString(4)+"</td><td>"+rs.getString(5)+"</td><td>"+rs.getString(6)+"</td><td>"+rs.getString(7)+"</td><td>"+rs.getString(8)+"</td></tr>");
con.close();
}
con.close();
}
%>
</table>
</body>
</html>


不会与数据库的连接 要用Access2003 越具体越好 大侠们救我啊
实在不行用SQL Server 也可以啊 在线关注~
...全文
125 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧