voit25
发贴: 7
|
于 2006-04-28 14:45
我的原文件::
<%@ 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></tr> <%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=voit25","sa",""); Statement stmt=con.createStatement(); ResultSet rst=stmt.executeQuery("select * from ID;"); while(rst.next()) { out.println("<tr>"); out.println("<td>"+rst.getString("name")+"</td>");
out.println("</tr>"); } //关闭连接、释放资源 rst.close(); stmt.close(); con.close(); %> </table> </body> </html>
错误是:::
Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:845) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:778) org.apache.jsp.conn_jsp._jspService(conn_jsp.java:77) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) 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(DriverManager.java:512) java.sql.DriverManager.getConnection(DriverManager.java:171) org.apache.jsp.conn_jsp._jspService(conn_jsp.java:53) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
YuLimin edited on 2006-05-02 10:26
|