启动tomcat后,只要有数据操作mysql服务就自动关闭?

今天把项目部署到服务器上时,报了一个error。
后来检查发现,mysql服务停止了,但是之前服务已经启动了。经过几次测试发现,没启动tomcat时,使用Navicat对数据库操作不会有问题,只要启动项目,一有数据操作就会自动停止mysql服务,这是什么情况?
错误信息如下:
2017-11-01 08:49:35,007 ERROR [com.alibaba.druid.pool.DruidDataSource] - create
connection error, url: jdbc:mysql://192.168.251.229:3306/creditteaching?useUnico
de=true&characterEncoding=utf-8, errorCode 0, state 08S01
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai
lure

The last packet sent successfully to the server was 0 milliseconds ago. The driv
er has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct

orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1
127)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:356)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2502)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2
539)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2321)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:832)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct

orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:417)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:344)
at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterCha
inImpl.java:148)
at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilte
r.java:211)
at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterCha
inImpl.java:142)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnecti
on(DruidAbstractDataSource.java:1410)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnecti
on(DruidAbstractDataSource.java:1464)
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(Dru
idDataSource.java:1969)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketI
mpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.ja
va:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocket
Impl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java
:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.(Socket.java:425)
at java.net.Socket.(Socket.java:241)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
va:258)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:306)
... 18 more

数据源使用的时druid,配置信息如下:


<!-- 数据源驱动类可不写,Druid默认会自动根据URL识别DriverClass -->








<property name="filters" value="stat" /> 

2个回答

建议楼主将Mysql服务改为手动,然后启动试一下,不行的话你在追问

m0_37711355
cocola丶 不行,改为手动了,服务还是自动停掉了
接近 3 年之前 回复

建议你检查下jdbc的连接字符串,下面是我一直用的写法

 jdbc:mysql://172.16.0.102:3306/ljzxdb?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false&useSSL=false
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问