Little_Wu_Wu
Little_Wu_Wu
2018-05-04 09:34
采纳率: 100%
浏览 2.4k
已采纳

tomcat启动报:Connection refused

Tomcat启动时报如下错误:
WARN : com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@118d1a82 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: (com.mchange.v2.resourcepool.BasicResourcePool#run ) 2018年05月04日17点02分
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.GeneratedConstructorAccessor52.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1129)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:358)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2498)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2535)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2320)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:834)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46)
at sun.reflect.GeneratedConstructorAccessor45.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.(Socket.java:434)
at java.net.Socket.(Socket.java:244)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:308)
... 19 more
说明:
1.刚开始查看mysql的运行状态是关闭的,然后启动mysql,启动成功;
图片说明
2.再次启动tomcat还是失败,然后查看防火墙,发现tomcat的8080端口,和mysql的3306端口未添加进去,然后添加了后重启防火墙,显示添加成功;
图片说明
3.再次启动还是失败,检查db.properties,测试通过,正确;
4.数据库权限:我的是用root账户连接数据库的,检查数据库发现也都有权限
注:tomcat和mysql在同一服务器中

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

10条回答 默认 最新

  • lu92649264
    lu92649264 2018-05-05 05:55
    已采纳

    a)虚拟机centos配置如下:vi /etc/hosts
    图片说明
    b)关闭防火墙
    c)杀死所有进程,重启tomcat
    查询tomcat所有进程: ps -ef |grep tomcat
    杀死进程:kill -9 端口号
    d)可以将web工程中pom的tomcat插件删除在添加然后安装,服务层manager工程中的pom的tomcat插件删除在添加安装
    数据库连接问题解决如图:
    图片说明

    点赞 评论
  • qq_37461349
    不喜欢吃猫的鱼 2018-05-04 09:50

    你的mysql端口映射出去的有没有限制啊,然后服务器的防火墙关闭一下确保可以通讯,看下有用不

    点赞 评论
  • qq_35511027
    点滴之水终成海 2018-05-04 09:50

    vi /etc/hosts

        在里边最下方添加一条记录
    
        格式:外网ip地址   服务器名称(此处为site01)
    
        例如: 222.222.222.222 site01
    
         即可
    
    点赞 评论
  • qq_39089301
    SpringCloud1 2018-05-04 09:51

    使用ps -eaf | grep tomcat命令查看是否有tomcat进程在使用
    如果发现有进程在运行,
    则用kill -9 Pid来杀掉这个进程,

    点赞 评论
  • dabocaiqq
    dabocaiqq 2018-05-04 10:37
    点赞 评论
  • feelcycle_07
    默默悟问 2018-05-04 13:50

    用mysql客户端看看能不能连接,能连接就不是mysql或防火墙的问题,不能就看mysql或者防火墙。

    点赞 评论
  • anning890118
    翱翔VW 2018-05-05 02:19

    tomcat和mysql在同一服务器中,如果是这样的话,你需要在你本地看下是否可以连通,如果本地可以的话,你要不就把你的代码的ip使用127的方式来走;

    点赞 评论
  • xiaoguokecsdn
    xiaoguokecsdn 2018-05-06 11:19

    防火墙、网络、数据库服务器状态,一个一个检查

    点赞 评论
  • Little_Wu_Wu
    Little_Wu_Wu 2018-05-07 01:16

    报错的tomcat在远程linux服务器上,我ping这个服务器的ip地址,ping不同;
    这个tomcat里还有另外一个项目,会不会是数据库的连接被沾满了?

    点赞 评论
  • Little_Wu_Wu
    Little_Wu_Wu 2018-05-07 01:56

    兄弟们,错误解决了,是tomcat里的另一个项目的数据库的配置错误,真是日了狗了,搞了一天多的时间!!!
    我这c币给lu92649264这位兄弟好了,这哥们走心了啊,虽然不是他给我解决的。

    点赞 评论

相关推荐