HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: An exception occurred processing JSP page /authors/index.jsp at line 129: String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books";
10: String username="sa";
11: String password="000000";
12: Connection conn = DriverManager.getConnection(url, username, password);
13: Statement state= conn.createStatement();
14: ResultSet rs = state.executeQuery("select * from authors");
15:  %>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause javax.servlet.ServletException: java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)
org.apache.jsp.authors.index_jsp._jspService(index_jsp.java:171)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books
java.sql.DriverManager.getConnection(DriverManager.java:602)
java.sql.DriverManager.getConnection(DriverManager.java:185)
org.apache.jsp.authors.index_jsp._jspService(index_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.

解决方案 »

  1.   

    <%@page import="java.sql.DriverManager"%>
    <%@page import="java.sql.Connection"%>
    <%@page import="java.sql.Statement"%>
    <%@page import="java.sql.ResultSet"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books";
    String username="sa";
    String password="000000";
    Connection conn = DriverManager.getConnection(url, username, password);
    Statement state= conn.createStatement();
    ResultSet rs = state.executeQuery("select * from authors");
     %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <style>
    .r1{
    background-image:url(../images/head1.jpg);
    background-repeat:repeat-x;}
    .t1{
    font-size:16px;
    height:20px;
    background-image:url(../images/headbg.jpg);
    background-repeat:repeat-x}
    a:link{
    color:#000000;
    text-decoration:none;}
    a:hover{color:#FF0000;
    text-decoration:underline;}
    .tbone{
    border:1px solid #CCCCCC;
    border-collapse:collapse;}
    .tbone th{
    color: #FFFFFF;
    background-color:#0066FF;
    border:1px solid #CCCCCC;}
    .tbone tr{
    border:1px solid #CCCCCC;}
    .tbone td{
    text-align:center;
    font-size:14px;
    background-color:#FFFFFF;
    border:1px solid #CCCCCC;}
    .tbone caption{
    font-size: 18px;
    border:0px solid #CCCCCC;}</style></head><body bgcolor="#F2F3FD" >
    <table cellpadding="0" align="center" width="100%" >
    <tr class="r1">
    <td><img src="../images/head.jpg" /></td>
    </tr>
    </table>
    <table align="center" width="100%" class="t1">
    <tr>
    <td>欢迎你[admin] |<a href="#">修改密码</a>|<a href="#">退出系统</a>|</td>
    <td align="right">|<a href="#">作者管理</a>|<a href="#">出版社管理</a>|<a href="#">图书管理</a>|<a href="#">图书查询</a>|<a href="#">用户管理</a>|</td>
    </tr>
    </table>
    <br />
    <table class="tbone" width="100%">
    <caption>作者列表</caption>
    <br />
    <tr>
    <th width="22%">作者ID</th>
    <th width="34%">名</th>
    <th width="34%">姓</th>
    <th>操作</th>
    </tr>
    <%
    while(rs.next()){
     %>
    <tr>
    <td><%=rs.getInt("authorID") %></td>
    <td><%=rs.getString("firstName") %></td>
    <td><%=rs.getString("lastName") %></td>
    <td align="center"><a href="#">修改</a>|<a href="#">删除</a></td>
    </tr>
    <%
    }
    rs.close();
    state.close();
    conn.close();
     %> </table></body>
    </html>
      

  2.   

    你不用加载数据库驱动吗?
    Class.forName加载试试。
      

  3.   

    jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books
    把:microsoft删了
      

  4.   

    +1楼主的驱动类写错了.你那写的是SQL2000的.
      

  5.   

    JAVA连接SQL2000语句为: 
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
    DriverManager.getConnection("jdbc:odbc:数据库名","数据库登录名","登录密码"); 但连接SQL2005,已经改为: 
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
    DriverManager.getConnection("jdbc:sqlserver://localhost:1433; DatabaseName=数据库名","数据库登录名","登录密码"); 
      

  6.   

    同志们还是不行啊  高人继续指点啊:<%@page import="java.sql.Connection"%>
    <%@page import="java.sql.DriverManager"%>
    <%@page import="java.sql.Statement"%>
    <%@page import="java.sql.ResultSet"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <%
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    Connection conn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433; DatabaseName=books","sa","000000"); 
    Statement stat = conn.createStatement();
    ResultSet rs = stat.executeQuery("select * from authors");
     %>
    结果还是:
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: An exception occurred processing JSP page /authors/index.jsp at line 96: <html xmlns="http://www.w3.org/1999/xhtml">
    7: <%
    8: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    9: Connection conn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433; DatabaseName=books","sa","000000"); 
    10: Statement stat = conn.createStatement();
    11: ResultSet rs = stat.executeQuery("select * from authors");
    12:  %>
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause javax.servlet.ServletException: com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection refused: connect
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)
    org.apache.jsp.authors.index_jsp._jspService(index_jsp.java:165)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection refused: connect
    com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
    com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
    com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
    com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
    com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    java.sql.DriverManager.getConnection(DriverManager.java:582)
    java.sql.DriverManager.getConnection(DriverManager.java:185)
    org.apache.jsp.authors.index_jsp._jspService(index_jsp.java:65)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
      

  7.   

    感觉没什么问题了,换下驱动或看下数据库配置问题,好象Sqlserver要配置什么端口什么的,没装Sqlserver,没法给测试
      

  8.   

    连接数据库的URL字符串写错了,既然用的是Server 2005,那就应该按照2005要求的字符串格式:
    jdbc:sqlserver://<server_name>:<port>[;databaseName=<dbname>] ;
    而下面这个是Server 2000的写法。
    jdbc:microsoft:sqlserver://<server_name>:<1433> 2000像这种简单的问题,如果记不住,打开Eclipse的MyEclipse Database browser 新建连接的地方就能开到所有数据库驱动连接的写法了。这只是你的其中一个明显的问题,不知道你的驱动版本是否是正确的。
      

  9.   

    同志们  你们辛苦了 我知道问题在哪了  我的SQL Server Configuration Manager 坏了 找不到 上网看了一些方法就行了 原来是SQL Server Configuration Manager 下的 TCP/IP 没启用 现在好了 谢谢大家了!!
      

  10.   

     String url="jdbc:sqlserver://localhost:1433;DatabaseName=books";
      

  11.   

    你还得看看你的数据库认证模式,如果你要用jdbc连接数据库那你要用sql server的认证模式。还要看看端口号。