Javaweb项目链接sqlserver 2008R2时出现的一系列的错误

好久没有弄java,玩eclipse了,最近因为小小的原因,参加一个比赛,不得不把javaweb的东西又捡起来,所以不熟悉,再加上之前链接数据库都是用Oracle的,现在公司的电脑上又只是安装了sqlserver 2008R2,所以就试着,开发项目链接sqlserver 2008R2。从昨天晚,到今天晚,终于算是搞定了一系列的问题,当页面显示出来的一刹那,好开心。人生就像打怪兽,就得一关一关地过。仅此,记录一下,辛苦的这些岁月,这活在当下的大好青春。

Javaweb项目链接sqlserver 2008R2时出现的一系列的错误
01    五月 28, 2014 9:21:02 下午 com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
02    警告: ConnectionID:1 ClientConnectionId: 10c92eac-e4c6-48d1-ba33-b50911fd4368 Prelogin error: host localhost port 8080 Unexpected end of prelogin response after 0 bytes read
03    com.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 8080 连接到主机 localhost 的 TCP/IP 连接失败。错误:“驱动程序收到意外的登录前响应。请验证连接属性,并检查 SQL Server 的实例正在主机上运行,且在此端口接受 TCP/IP 连接。该驱动程序只能与 SQL Server 2000 或更高版本一起使用。”。 ClientConnectionId:10c92eac-e4c6-48d1-ba33-b50911fd4368
04        at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
05        at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1654)
06        at com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:1442)
07        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1319)
08        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
09        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
10        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
11        at java.sql.DriverManager.getConnection(Unknown Source)
12        at java.sql.DriverManager.getConnection(Unknown Source)
13        at com.news.util.DbUtil.getcon(DbUtil.java:18)
14        at com.news.daoImpl.TopicDaoImpl.displayTopic(TopicDaoImpl.java:17)
15        at org.apache.jsp.index_jsp._jspService(index_jsp.java:147)
16        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
17        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
18        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
19        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
20        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
21        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
22        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
23        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
24        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
25        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
26        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
27        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
28        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
29        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
30        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
31        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
32        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
33        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
34        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
35        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
36        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
37        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
38        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
39        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
40        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
41        at java.lang.Thread.run(Unknown Source)
Javaweb项目链接sqlserver 2008R2时出现的一系列的错误

 

 

查看了080端口,没看太明白,应该怎么解决?

Javaweb项目链接sqlserver 2008R2时出现的一系列的错误

 

8080是项目访问服务器的端口 不是数据库访问的端口  端口号改为1433后 报错

Javaweb项目链接sqlserver 2008R2时出现的一系列的错误
01    com.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。错误:“Connection refused: connect。请验证连接属性。确保 SQL Server 的实例正在主机上运行,且在此端口接受 TCP/IP 连接,还要确保防火墙没有阻止到此端口的 TCP 连接。”。
02        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
03        at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
04        at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
05        at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
06        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
07        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
08        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
09        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
10        at java.sql.DriverManager.getConnection(Unknown Source)
11        at java.sql.DriverManager.getConnection(Unknown Source)
12        at com.news.util.DbUtil.getcon(DbUtil.java:18)
13        at com.news.daoImpl.TopicDaoImpl.displayTopic(TopicDaoImpl.java:17)
14        at org.apache.jsp.index_jsp._jspService(index_jsp.java:147)
15        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
16        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
17        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
18        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
19        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
20        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
21        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
22        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
23        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
24        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
25        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
26        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
27        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
28        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
29        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
30        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
31        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
32        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
33        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
34        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
35        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
36        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
37        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
38        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
39        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
40        at java.lang.Thread.run(Unknown Source)
Javaweb项目链接sqlserver 2008R2时出现的一系列的错误

解决方法:从“开始”里的“所有程序” 里打开 “microsoft sqlserver 2008R2 ”的 SQL Server Configuration Manager(配置管理),然后下图中启用TCP/IP协议。

Javaweb项目链接sqlserver 2008R2时出现的一系列的错误

接着,重启数据库服务:电脑-管理-服务和应用--启动数据库服务

Javaweb项目链接sqlserver 2008R2时出现的一系列的错误

 

 

Javaweb项目链接sqlserver 2008R2时出现的一系列的错误,布布扣,bubuko.com

Javaweb项目链接sqlserver 2008R2时出现的一系列的错误

上一篇:使用PL/SQL客户端连接远程oracle数据库


下一篇:SQL外键的作用