• com.microsoft.sqlserver.jdbc.SQLServerException: 到主机 的 TCP/IP 连接失败


    1、错误描述

    2017-04-05 11:30:08,031 [localhost-startStop-1] DEBUG [org.springframework.jdbc.core.JdbcTemplate] - Executing SQL query [select getdate()]
      2017-04-05 11:30:29,163 [localhost-startStop-1] ERROR [com.alibaba.druid.pool.DruidDataSource] - init datasource error
      com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect
    	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:148)
    	at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)
    	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)
    	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1377)
    	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1431)
    	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:618)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:915)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:911)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:98)
    	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:388)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:468)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:478)
    	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:488)
    	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:494)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1101)
    	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1786)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    2017-04-05 11:30:29,195 [localhost-startStop-1] ERROR [com.alibaba.druid.pool.DruidDataSource] - dataSource init error
      com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect
    	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:148)
    	at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)
    	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)
    	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1377)
    	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1431)
    	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:618)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:915)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:911)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:98)
    	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:388)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:468)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:478)
    	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:488)
    	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:494)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1101)
    	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1786)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    2017-04-05 11:30:29,197 [localhost-startStop-1] INFO  [com.alibaba.druid.pool.DruidDataSource] - {dataSource-1} inited
      2017-04-05 11:30:29,200 [localhost-startStop-1] INFO  [com.alibaba.druid.pool.DruidDataSource] - {dataSource-1} closed
      2017-04-05 11:30:29,201 [localhost-startStop-1] ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adviceMesSupport': Injection of autowired dependencies failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1101)
    	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1786)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:388)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:468)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:478)
    	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:488)
    	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:494)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    	... 26 more
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect
    	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:148)
    	at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)
    	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)
    	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1377)
    	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1431)
    	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:618)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:915)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:911)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:98)
    	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
    	... 40 more
    四月 05, 2017 11:30:29 上午 org.apache.catalina.core.StandardContext listenerStart
    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adviceMesSupport': Injection of autowired dependencies failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1101)
    	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1786)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:388)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:468)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:478)
    	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:488)
    	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:494)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    	... 26 more
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect
    	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:148)
    	at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)
    	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)
    	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1377)
    	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1431)
    	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:618)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:915)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:911)
    	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:98)
    	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
    	... 40 more

    2、错误原因

          本地连接SQL Server数据库,未打开telnet协议


    3、解决办法

    (1)打开开始输入“cmd”,在命令窗口输入:telnet 127.0.0.1

    (2)如果提示“不是内部命令”,需要设置telnet协议‘

    (3)控制面板--->程序--->打开或关闭Windows功能,将telnet客户端和服务端都勾选上

    (4)计算机--->管理--->服务--->开启telnet服务

  • 相关阅读:
    mysql报错排查总结
    java设计模式--外观模式
    java设计模式--策略模式
    java设计模式--策略模式
    java设计模式--简单工厂
    java设计模式--简单工厂
    国外有哪些比较好的IT社区
    使用jmeter进行性能测试-Jmeter教程及技巧汇总 (转)
    Fiddler环境配置教程
    Fiddler+Jmeter+断言详细教程
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313902.html
Copyright © 2020-2023  润新知