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

您没有登录

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

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 jdbc连接sqlserver2000时报错
ericgk2000





发贴: 2
积分: 0
于 2006-04-07 09:17 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
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=BookSotre";
String user="Eric";
String password="gk2000";
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433","Eric","gk2000");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from book_details_list";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
这个例子怎么都调不通,实在是郁闷.
报错如下
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: Exception in JSP: /test.jsp:9

6: String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=BookSotre";
7: String user="Eric";
8: String password="gk2000";
9: Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433","Eric","gk2000");
10: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
11: String sql="select * from book_details_list";
12: ResultSet rs=stmt.executeQuery(sql);

Stacktrace:
  org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
  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.test_jsp._jspService(test_jsp.java:85)
  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.test_jsp._jspService(test_jsp.java:51)
  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.

--------------------------------------------------------------------------------

Apache Tomcat/5.5.16




微信支付demo

话题树型展开
人气 标题 作者 字数 发贴时间
12259 jdbc连接sqlserver2000时报错 ericgk2000 4271 2006-04-07 09:17
10021 Re:jdbc连接sqlserver2000时报错 jeason1914 5 2006-04-07 12:19
9934 Re:jdbc连接sqlserver2000时报错 ericgk2000 10 2006-04-08 10:38
9755 Re:jdbc连接sqlserver2000时报错 bishan 56 2006-05-09 09:43
9740 Re:jdbc连接sqlserver2000时报错 K_P_exciting 337 2006-05-19 21:22
10225 Re:jdbc连接sqlserver2000时报错 yclc 41 2006-07-08 15:07

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