Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 JDBC连接SQLSERVER数据库出错。请大家帮忙
huajiazhou





发贴: 14
积分: 0
于 2005-04-05 12:01 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
原程序如下:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>连接数据库的例子</title>
</head>
<body>
以下是从MS SQLserver数据库中读出的数据:<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();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jspdev";
String USER="sa";
String PWD="5696285";
Connection con= DriverManager.getConnection(url,USER,PWD);
Statement stmt=con.createStatement();
String inq="select * from book";
ResultSet rst=stmt.executeQuery(inq);
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>
以下是错误提示:
type 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:825)
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
  org.apache.jsp.testMssql2_jsp._jspService(testMssql2_jsp.java:118)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
  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:810)

请大家帮我看看这到底是什么问题!数据库的用户名跟密码绝对没错!JDBCFORSQLSERVER驱动放到了LIB文件夹里面了!数据库里面有我连接的这个数据库!多谢


huajiazhou edited on 2005-04-05 16:46


如何用JTable设置表头多行

话题树型展开
人气 标题 作者 字数 发贴时间
9656 JDBC连接SQLSERVER数据库出错。请大家帮忙 huajiazhou 2412 2005-04-05 12:01
7966 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 huajiazhou 40 2005-04-05 14:35
7898 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 sogui 76 2005-04-05 16:07
7913 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 huajiazhou 38 2005-04-05 16:47
7871 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 why 140 2005-04-05 19:33
7848 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 huajiazhou 92 2005-04-05 23:29
7833 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 alexwish 47 2005-04-06 10:28
7937 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 huajiazhou 44 2005-04-06 12:32
7959 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 huajiazhou 131 2005-04-06 19:42
7998 Re:JDBC连接SQLSERVER数据库出错。请大家帮忙 西北狼 92 2005-04-19 00:11

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923