刚才哪个问题还是没有解决, 请大吓在帮帮忙!!1

freedom1980 2004-09-01 08:08:27
package myclass;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Lookup {
String goodsname;
String introduction;
String unit;
String company;
Float price;
Integer total;
Statement stmt=null;
ResultSet st=null;
String sql="select goodsname,introduction,unit,company,price,total from goods";
ServletContext application;
public void excuteQury(){
try{
st=ConnectSql.executeQuery(sql);// 问题就出在这里,
if(st.next()){

application.setAttribute("goodsname",st.getString("goodsname"));
application.setAttribute("introduction",st.getString("introduction"));
application.setAttribute("unit",st.getString("unit"));
application.setAttribute("company",st.getString("company"));
application.setAttribute("price",st.getString("price"));
application.setAttribute("total",st.getString("total"));

}
stmt.close();
st.close();
}catch(SQLException e){
System.out.println("the sql error:"+e.getMessage());
}

}
}

错误就一个提示找不到ConnectSql
ConnectSql 是public 是和Lookup一个包啊 怎么不能调用他的方法
...全文
47 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
freedom1980 2004-09-01
set classpath=.;d:\jdk1.4\lib\tools.jar;d:\jdk1.4\jre\lib\ext\servlet.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar
这两个程序编译后都放在D:\tomcat4.1\webapps\examples\WEB-INF\classes\myclass里面的
回复
pingfan520 2004-09-01
ConnectSql和Lookup一个包,不明白楼主的意思
那你import Lookup.*;看看咯
回复
一点晴 2004-09-01


确定CLASSPATH设置正确,并且2个源文件放在同一包中再编译!
回复
freedom1980 2004-09-01
package myclass;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Lookup {
String goodsname;
String introduction;
String unit;
String company;
Float price;
Integer total;
Statement stmt=null;
ResultSet st=null;
ConnectSql cql=new ConnectSql();//还是出错啊!!!!!
String sql="select goodsname,introduction,unit,company,price,total from goods";
ServletContext application;
public void excuteQury1(){
try{
st=cql.executeQuery(sql);
if(st.next()){

application.setAttribute("goodsname",st.getString("goodsname"));
application.setAttribute("introduction",st.getString("introduction"));
application.setAttribute("unit",st.getString("unit"));
application.setAttribute("company",st.getString("company"));
application.setAttribute("price",st.getString("price"));
application.setAttribute("total",st.getString("total"));

}
stmt.close();
st.close();
}catch(SQLException e){
System.out.println("the sql error:"+e.getMessage());
}

}
}

没用的Lookup.java:14: cannot resolve symbol
symbol : class ConnectSql
location: class myclass.Lookup
ConnectSql cql=new ConnectSql();
^
Lookup.java:14: cannot resolve symbol
symbol : class ConnectSql
location: class myclass.Lookup
ConnectSql cql=new ConnectSql();
^
2 errors

回复
TinyJimmy 2004-09-01
天哪就这个问题, 都看了三贴了.
你要初始化一个实例

ConnectSql cs = new ConnectSql();
st=cs.executeQuery(sql);//
回复
一点晴 2004-09-01


回楼上的,他的ConnectSql类里一个static方法都没有
回复
schwarzenegger 2004-09-01
ConnectSql.executeQuery(sql);// 是static吗?
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-01 08:08
社区公告
暂无公告