错误提示:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375) 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
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791) org.apache.jsp.testMssql_jsp._jspService(testMssql_jsp.java:99) 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)
root cause
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. 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.TDSConnection.<init>(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(Unknown Source) java.sql.DriverManager.getConnection(Unknown Source) org.apache.jsp.testMssql_jsp._jspService(testMssql_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.16 logs.
代码文件:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.io.*"%>
<html>
<body>
以下是从Ms sql server数据库读取的数据:<hr>
<table border=1>
<tr><td>id</td><td>书名</td><td>出版社</td><td>价格</td></tr>
<%! String trans(String chi)
{
String result = null;
byte temp [];
try
{
temp=chi.getBytes("iso-8859-1");
result = new String(temp);
}
catch(UnsupportedEncodingException e)
{
System.out.println (e.toString());
}
return result;
}
%>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev","sa","");
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery("select * from book;");
while(rst.next())
{
out.println("<tr>");
out.println("<td>"+trans(rst.getString("bookId"))+"</td>");
out.println("<td>"+trans(rst.getString("bookName"))+"</td>");
out.println("<td>"+trans(rst.getString("publisher"))+"</td>");
out.println("<td>"+rst.getFloat("price")+"</td>");
out.println("</tr>");
}
//关闭连接、释放资源
rst.close();
stmt.close();
con.close();
%>
</table>
</body>
</html>
哪位大侠帮帮我