我用Tomcat5.5 数据库为SQL2000,我已经打过补丁,但就是连接不上,各位高手帮帮我。
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.lang.NullPointerException
org.apache.jsp.db_jsp._jspService(db_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

解决方案 »

  1.   

    唉,我实在不知道怎么弄了,能帮我看看代码哪不对吗?多谢了!
    <body> <%
    String dbDriver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();   
    String url="jdbc:sqlserver://localhost:1433;databaseName=ticketorder";
    String user="sa"; 
    String password="123"; 
    Connection Conn=null;
    ResultSet rs=null;
    Statement stmt=null;
    try{
    Class.forName(dbDriver);
    Conn=DriverManager.getConnection(url,user,password);
    stmt=Conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);   
    String sql="select * from admin";   rs=stmt.executeQuery(sql);  
    }
    catch(Exception ex){
    System.out.println(ex+"Error");
    }
     
    while(rs.next()) {
    %>   
    test<br><%}%>   
    <%out.print("数据库操作成功");%>   <br>
    <%rs.close();   
    stmt.close();   
    Conn.close();   
    %>   
    </body> 
      

  2.   

    如果是连不上数据库,conn可能是null---是不是没有引入驱动啊?
      

  3.   

    是不是msbase.jar\mssqlserver.jar\msutil.jar这三个驱动啊?我都放在tomcat的确lib下了啊
      

  4.   

    这3个驱动可以放入到工程的lib下面试试,代码是没有问题的
      

  5.   

    建议重启一下tomcat或者重装tomcat
      

  6.   

    在SQL Server 2000 中加载驱动和URL路径的语句是String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String dbURL = "jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=sample";而SQL Server 2005 中加载驱动和url的语句则为String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=sample";可以看出版本不同连接方法也是不同的。SQL Server有许多不同版本,看你用的是哪个了。 ===========================================================================
    String dbDriver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
    你这开始的两行就矛盾了。 
      

  7.   

    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();  
    Class.forName(dbDriver);怎么写了两个
      

  8.   

    url:jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=sample
    补丁sp3
      

  9.   

    我打过补丁sp3 sp4
    不用hibernate都可以用