初写javabean时遇到的问题

moyancn 2003-04-07 11:14:36
demo.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>客户信息调查</title>
</head>
<body>
<p><b>客户信息调查</b></p>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="DB" scope="page" class="DBconn"/>
<%
ResultSet rs=DB.executeQuery("select * from EG_TASK order by id");
while (rs.next()){
out.print("<LI>"+rs.getString("TASK_NAME")+"<LI>");
out.print("<LI>"+rs.getInt("TASK_LEVEL")+"<LI>");
out.print("<LI>"+StartTime=rs.getDate("TASK_STARTTIME")+"<LI>");
}
rs.close();
%>
</body>
</html>
学习调用javaBean,可是有问题,不知为何?
import java.sql.*;
public class DBconn{
String DBdrive="public PreparedStatement getUpdatedPstmt()";
String ConnStr="jdbc:oracle:thin:@192.168.0.8:1521:develop";
Connection Conn=null;
ResultSet Rs=null;
public DBconn(){
try{
Class.forName(DBdrive);
}catch(ClassNotFoundException e){
System.out.println("DBconn():"+e.getMessage());
}
}
public ResultSet executeQuery(String sql){
Rs=null;
try{
Conn = DriverManager.getConnection(ConnStr, "szhr", "szhr123");
Statement stmt=Conn.createStatement();
Rs=stmt.executeQuery(sql);
}catch(SQLException e){
System.out.println(e.getMessage());
}
return Rs;
}
}
文件的位置都没放错,jsp在tomcat的example下,javabean在web-inf的classes中,可是tomcat提示org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 8 in the jsp file: /demo.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\demo_jsp.java:54: cannot resolve symbol
symbol : class DBconn
location: class org.apache.jsp.demo_jsp
DBconn DB = null;
^



An error occurred at line: 8 in the jsp file: /demo.jsp

Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\demo_jsp.java:56: cannot resolve symbol
symbol : class DBconn
location: class org.apache.jsp.demo_jsp
DB = (DBconn) pageContext.getAttribute("DB", PageContext.PAGE_SCOPE);
^



An error occurred at line: 8 in the jsp file: /demo.jsp

Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\demo_jsp.java:59: cannot resolve symbol
symbol : class DBconn
location: class org.apache.jsp.demo_jsp
DB = (DBconn) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "DBconn");
^



An error occurred at line: 9 in the jsp file: /demo.jsp

Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\demo_jsp.java:74: cannot resolve symbol
symbol : variable StartTime
location: class org.apache.jsp.demo_jsp
out.print(""+StartTime=rs.getDate("TASK_STARTTIME")+"");
^
4 errors
为什么呢,搞不懂,希望高手指点!
...全文
9 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
struggle007csdn 2003-04-07
你这样调用的话。JAVABEAN这个文件一定要放在一个包下。
回复
zez 2003-04-07
bean有没有设置包 ?
就是package ...
没有建议加上,包名自定...
我没遇到过类似问题,不过见别人讨论过,好像必须要用包的...
回复
jcq 2003-04-07
建议你将你的class加一句:
package就是使用一个包,然后再试试,还有就是你的StartTime没有定义
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2003-04-07 11:14
社区公告
暂无公告