求助:jsp连接Access连接报错!在线急等,一定给分!

jianbo99 2006-02-23 10:23:58
我用的是javabean的方法连接access库,报错情况如下:
exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 3 in the jsp file: /conn_db.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\conn_005fdb_jsp.java:43: package student does not exist
student.conn connDbBean = null;
^
An error occurred at line: 3 in the jsp file: /conn_db.jsp




javabean的程序如下:
package student;
import java.sql.*;
public class conn{
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr="jdbc:odbc:student";
Connection connect=null;
ResultSet rs=null;
public conn(){
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println(e.getMessage());
}
}
public ResultSet executeQuery(String sql){
try{
connect=DriverManager.getConnection(sConnStr);
Statement stmt=connect.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println(ex.getMessage());
}
return rs;
}

}


jsp程序如下:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="connDbBean" scope="page" class="student.conn"/>
<html>
<head>
<title>测试数据库连接</title>
</head>
<body bgcolor="#ffffff">
<div align="center">
<table width="60%" border="1">
<tr bgcolor="#ccccff">
<td width="50%">
<div align="center"><font color="#ff0033"><b>姓名</b></font></div>
</td>
<td width="25%">
<div align="center"><font color="#ff0033"><b>性别</b></font></div>
</td>
<td width="25%">
<div align="center"><font color="#ff0033"><b>分数</b></font></div>
</td>
</tr>
<%
ResultSet RS_result=connDbBean.executeQuery("select * from table1");
String studentName="";
String studentSex="";
int studentScore=0;
while(RS_result.next())
{
studentName=RS_result.getString("name");
studentSex=RS_result.getString("sex");
studentScore=RS_result.getInt("score");
%>
<tr>
<td width="50%" bgcolor="#ffffff">
<div align="center"><%=studentName %></div>
</td>
<td width="25%" bgcolor="#ffffff">
<div align="center"><%=studentSex %></div>
</td>
<td width="25%" bgcolor="#ffffff">
<div align="center"><%=studentScore %></div>
</td>
</tr>
<%
}
RS_result.close();
%>
</table>
</div>
</body>
</html>

求各位大虾帮我解决一下,在线等,一定加分!

...全文
69 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jianbo99 2006-02-23
谢谢搞定
回复
infowain 2006-02-23
错误是:package student does not exist
你的javabean编译好了吗?
编译好之后的conn.class应该放在WEB-INF\classes\student目录里面
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-02-23 10:23
社区公告
暂无公告