各位大侠求救!!!!(50分)

  • 主题发起人 主题发起人 zlc_168
  • 开始时间 开始时间
Z

zlc_168

Unregistered / Unconfirmed
GUEST, unregistred user!
下载了Microsoft SQL Server 2000 Driver for JDBC,并且将LIB下的三个.JAR文件设置
到CLASSPATH系统环境变量中,但是在servlet中应用时,会报ClassNotFouncException(类未
找到的错误),请大侠HELP!!!
 
我将环境变量等设置情况写在下面:
web server:apache_1_3_12_win32.exe,安装在c:/apache;
servlet容器:ApacheJServ-1.1.2-2.exe,安装在c:/Apache JServ 1.1.2;
j2sdk:j2sdk-1_3_1_07-windows-i586.exe,安装在c:/jdk1.3.1_07;
tomcat:jakarta-tomcat-3.2.3.zip,安装在c:/jtomcat
jdbc:Microsoft SQL Server 2000 Driver for JDBC,安装在d:/program file/Microsoft SQL Server 2000 Driver for JDBC下
classpath设置:c:/jdk1.3.1_07/lib/tools.jar;c:/jdk1.3.1_07/lib/dt.jar;c:/jdk1.3.1_07/user;c:/jtomcat/lib/servlet.jar;c:/jdk1.3.1_07/lib/msbase.jar;c:/jdk1.3.1_07/lib/mssqlserver.jar;c:/jdk1.3.1_07/lib/msutil.jar
其中将JDBC FOR SQL SERVER三个文件拷贝到c:/jdk1.3.1_07/lib下;
path设置:
c:/jdk1.3.1_07/bin
tomcat的PORTS设置为8080;
在c:/下编译servlet文件DBConnect.java,出错信息为:
凡是有JDBC类的地方均为 can not resolve symbol
源代码为:
import com.microsoft.jdbc.sqlserver.SQLServerDriver;
import java.net.*;
import java.lang.*;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
public class DBConnect extends GenericServlet{
private Connection dcon=null;
public void init(ServletConfig con) throws ServletException{
super.init(con);
String driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs;User=sa;password=";
try{
Class.forName(driver);
dcon=DriverManager.getConnetion(url);
}
cathch(Exception ex){
system.out.println(ex.toString());
}
}
public void service(ServletRequest req,ServletResponse res) throws ServletException.IOException{
String sqlstr="select * from jobs";
Statement lstmt=dcon.CreateStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=lstmt=con.executeQuery(sqlstr);
res.setContentType("text/html");
PrintWriter out = response.getWriter()
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
lsmt.last();

int num=lsmt.getRow();


if (num==0){
out.println("<h1>数据库中无记录!</h1>");
}
else
{
lsmt.first();
while (lsmt.next()){
out.println("<tr><td>"+lstmt.getString("job_id")+"</td>");
out.println("<td>"+lstmt.getString("job_desc")+"</td></tr>");
}

}
out.println("</body>");
out.println("</html>");
lstmt.close();
}
public void destroy{
dcon.close()
}
}
难道没有人知道吗?
 
UP
java初学者,对java的环境配置,晕!
classpath C:/Program Files/Java/j2sdk1.4.1_02/lib/tools.jar;
 
你不也是这样过来的吗?
 
接受答案了.
 
后退
顶部