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:54: package com.microsoft.jdbc does not exist
Class.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver);
                                ^
1 error
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)===============================================================
我已经把JDBC三个jar文件copy到了tomcat的common\lib下了,并且再次copy到JDK的web-info的lib下了,但是还是错误,不知道为什么,希望大家帮我解决下

解决方案 »

  1.   

    Class.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver);
    你在classpath里指向了sql的3个驱动包了吗
      

  2.   

    已经指向了的,我在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>==================================
    望大家帮忙解决下啊,急啊!!!!谢谢!
      

  3.   

    stmt与con根本在程序中没有被定义..而到最后却让它们都close(关闭),当然要报错了....
    你再看看书..你写的那些少好多东东....
    还有"........SQLServerDriver"你的这个驱动也根本没有...
      

  4.   

    Connection con = null;
    Statement stmt = null;
    ResultSet result=null;
    try{
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jspdev","QJ","");
    stmt=con.createStatement();
    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();