Topic: jdbc连接sqlserver2000时报错 |
Print this page |
1.jdbc连接sqlserver2000时报错 | Copy to clipboard |
Posted by: ericgk2000 Posted on: 2006-04-07 09:17 <%@ 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 |
2.Re:jdbc连接sqlserver2000时报错 [Re: ericgk2000] | Copy to clipboard |
Posted by: jeason1914 Posted on: 2006-04-07 12:19 写法有问题 |
3.Re:jdbc连接sqlserver2000时报错 [Re: ericgk2000] | Copy to clipboard |
Posted by: ericgk2000 Posted on: 2006-04-08 10:38 请问写法哪里有问题? |
4.Re:jdbc连接sqlserver2000时报错 [Re: ericgk2000] | Copy to clipboard |
Posted by: bishan Posted on: 2006-05-09 09:43 我连接数据库时也出现这种问题,麻烦问一下,你现在解决了这个问题没?若是知道的话麻烦给我这个新手说一下原因,谢谢! |
5.Re:jdbc连接sqlserver2000时报错 [Re: ericgk2000] | Copy to clipboard |
Posted by: K_P_exciting Posted on: 2006-05-19 21:22 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"); 直接用Connection conn = DriverManager.getConnection(url, "Eric", "gk2000"); 参数1是URL,应该要有数据库名字的。 |
6.Re:jdbc连接sqlserver2000时报错 [Re: ericgk2000] | Copy to clipboard |
Posted by: yclc Posted on: 2006-07-08 15:07 you'll success after do a mssql SP3 patch |
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 |