| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 577 人关注过本帖
标题:[求助]连接数据库出错了!
只看楼主 加入收藏
暴暴蛇
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-3-16
收藏
 问题点数:0 回复次数:0 
[求助]连接数据库出错了!

错误提示:

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>


哪位大侠帮帮我

搜索更多相关主题的帖子: 数据库 style ffffff 
2006-05-21 17:11
快速回复:[求助]连接数据库出错了!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028169 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved