已经指向了的,我在CLASSPATH里添加了JDBC三个.jar文件,并且在JDK1.4\jre\lib\ext\下也添加了那三个文件,但是还是出错。=========================================================================================
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 11 in the jsp file: /sunone/ch11/testmssql.jspGenerated servlet error:
    [javac] Compiling 1 source fileF:\tomcat\work\Catalina\localhost\_\org\apache\jsp\sunone\ch11\testmssql_jsp.java:55: package com.microsoft.jdbc does not exist
Class.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver);
                                ^An error occurred at line: 11 in the jsp file: /sunone/ch11/testmssql.jspGenerated servlet error:
F:\tomcat\work\Catalina\localhost\_\org\apache\jsp\sunone\ch11\testmssql_jsp.java:67: cannot resolve symbol
symbol  : variable result 
location: class org.apache.jsp.sunone.ch11.testmssql_jsp
result.close();
^An error occurred at line: 11 in the jsp file: /sunone/ch11/testmssql.jspGenerated servlet error:
F:\tomcat\work\Catalina\localhost\_\org\apache\jsp\sunone\ch11\testmssql_jsp.java:68: cannot resolve symbol
symbol  : variable stmt 
location: class org.apache.jsp.sunone.ch11.testmssql_jsp
stmt.close();
^An error occurred at line: 11 in the jsp file: /sunone/ch11/testmssql.jspGenerated servlet error:
F:\tomcat\work\Catalina\localhost\_\org\apache\jsp\sunone\ch11\testmssql_jsp.java:69: cannot resolve symbol
symbol  : variable con 
location: class org.apache.jsp.sunone.ch11.testmssql_jsp
con.close();
^
4 errors
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:83)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:306)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:374)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:417)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:398)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:507)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:277)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:223)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0 logs.
=========================================================================================源程序为<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
</head>
<body>
MSSQL数据库<br>
<hr>
<%
try{
Class.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver);
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jspdev","QJ","");
Statement stmt=con.createStatement();
ResultSet result=stmt.executeQuery("select * from book;");
while(result.next()){
out.print(result.getString("bookId"));
out.print(result.getString("bookName"));
out.print(result.getString("publisher"));
out.print(result.getFloat("price"));
}
}catch(Exception e){
}
result.close();
stmt.close();
con.close();
%>
</body>
</html>==================================
望大家帮忙解决下啊,急啊!!!!谢谢!

解决方案 »

  1.   

    你是web应用吗?要加在web-inf/lib里!
      

  2.   

    你是用什么编译工具阿?
    把那几个jar拷贝到你的Tomcat目录\lib\下
      

  3.   

    1:Class.forName(..)参数应该是字符串,所以按照你的程序,应该是
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");2:你是否已经把含com.microsoft.jdbc.sqlserver.SQLServerDriver类的JAR包假如到classpath中?这个包是MS SQL SERVER的JDBC包,J2SDK本身是不带的。
      

  4.   

    你的错误好多!
    3:Statement stmt=con.createStatement();定义在try{...}里面,而你的stmt.close();在外面,已经出了作用域了,相当于对stmt.close();这句来说,stmt是没有定义过的对象!!!
    其他
    result.close();
    con.close();相同道理
      

  5.   

    把SQLServer驱动放到WEB-INF下的lib里
      

  6.   

    谢谢大家的帮助
    我现在把try{} catch{}块移除了,结果报错,但是不移除的话,从数据库里出不了数据啊
    ============================================
    type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Connection reset
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:822)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:755)
    org.apache.jsp.sunone.ch11.testmssql_jsp._jspService(testmssql_jsp.java:78)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:268)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:277)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:223)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    root cause java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Connection reset
    com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
    com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
    com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
    com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
    com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
    com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
    java.sql.DriverManager.getConnection(DriverManager.java:512)
    java.sql.DriverManager.getConnection(DriverManager.java:171)
    org.apache.jsp.sunone.ch11.testmssql_jsp._jspService(testmssql_jsp.java:55)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:268)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:277)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:223)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0 logs.
    ================================================
    这会是什么原因呢???
      

  7.   

    这个可能是你SQL SERVER的问题了,比如端口是否正确,服务是不是启动了,用户名密码对吗?数据库名称对吗?(不是服务名称)
      

  8.   

    好的,谢谢 darkattack兄了
    分发分数了,呵呵