这个错误怎么解决?

itzhiren 2006-03-17 09:12:03
D:\Tomcat 4.1\work\Standalone\localhost\jsp\yonghuguanli\reg2_jsp.java:57: cannot resolve symbol
symbol : class opendb
location: class opendb.opendb
opendb.opendb db = null;
...全文
91 点赞 收藏 15
写回复
15 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
itzhiren 2006-03-18
谢谢大家的回复,问题我自己解决了
回复
itzhiren 2006-03-17
是的,放在classes\opendb下
回复
scottwhb 2006-03-17
你的class放在什么位置
是在classes\opendb下吗?
回复
itzhiren 2006-03-17
路径没有问题的
回复
appleangle 2006-03-17
class="opendb.opendb" />
检查你的路径是不是对了
回复
itzhiren 2006-03-17
大家帮忙看看调用得对不对呀?
回复
itzhiren 2006-03-17
<%@ page import="opendb.*"%>
<jsp:useBean id="db" scope="page" class="opendb.opendb" />
<%
//判断所选的用户ID是否与现有ID重名
String uid=request.getParameter("uid");
//生成查询的sql命令
String sql="select * from custom where uid='"+uid+"'";
//rs为返回结果的ResultSet对象
ResultSet rs=db.executeQuery(sql);

就是这样调用的
回复
feixianking 2006-03-17
reg2_jsp里面你是怎么调用的呢?
回复
itzhiren 2006-03-17
沉得太快了,高手们,帮帮我呀
回复
itzhiren 2006-03-17
//定义包opendb
package opendb;
//引入java.sql.*
import java.sql.*;
//包opendb中的类opendb
public class opendb
{
//定义数据库连接字符串,jdbc.odbc桥
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr="jdbc:odbc:JSP";
Connection conn=null;
ResultSet rs=null;
//定义打开数据库连接的函数
public opendb()
{
try{
Class.forName("sDBDriver");
}
//处理异常
catch (java.lang.ClassNotFoundException e){
System.err.println("opendb():"+e.getMessage());
}
}
//定义执行SQL语句的函数
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
conn=DriverManager.getConnection(sConnStr,"sa","");
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
//异常处理
catch (SQLException ex)
{
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return rs;
}
}

以上就是opendb.java的完整源码
回复
itzhiren 2006-03-17
类我已经在定义了呀,我用的是javaBean:
<jsp:useBean id="db" scope="page" class="opendb.opendb" />
调用包opendb中的opendb类,有什么错误吗?
回复
wizardblue 2006-03-17
cannot resolve symbol:一般是找不到相对应的类型或者类
回复
itzhiren 2006-03-17
不行,我改成
<%@ page import="opendb.*"%>
<jsp:useBean id="db" scope="page" class="opendb" />

,有以下错误:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: opendb
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:498)
at org.apache.jsp.reg2_jsp._jspService(reg2_jsp.java:270)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)

回复
mumi0422 2006-03-17
<%@ page import="opendb.*"%>
<jsp:useBean id="db" scope="page" class="opendb.opendb" />
你写重复啦
因为你已经import这个包下的所有类啦
所以在你指定class的时候就不用写这个包名啦


<%@ page import="opendb.*"%>
<jsp:useBean id="db" scope="page" class="opendb" />


<%@ page contentType="text/html;charset=GB2312"%>
<jsp:useBean id="db" scope="page" class="opendb.opendb" />

回复
itzhiren 2006-03-17
高手们,帮我看看怎么解决呀?
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-03-17 09:12
社区公告
暂无公告