最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

CannotcreatePoolableConnectionFactory(Communicationslink_MySQL

来源:懂视网 责编:小采 时间:2020-11-09 20:11:49
文档

CannotcreatePoolableConnectionFactory(Communicationslink_MySQL

CannotcreatePoolableConnectionFactory(Communicationslink_MySQL:bitsCN.com 今天在做web项目的时候碰到了这样的一个异常:Caused by: java.lang.RuntimeException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communic
推荐度:
导读CannotcreatePoolableConnectionFactory(Communicationslink_MySQL:bitsCN.com 今天在做web项目的时候碰到了这样的一个异常:Caused by: java.lang.RuntimeException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communic

bitsCN.com

今天在做web项目的时候碰到了这样的一个异常:

Caused by: java.lang.RuntimeException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)	at edu.gzucm.yjsglxt.base.util.TimeSetUtils.getTimeSets(TimeSetUtils.java:52)	at edu.gzucm.yjsglxt.base.util.TimeSetUtils.(TimeSetUtils.java:22)	... 3 moreCaused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)	at edu.gzucm.yjsglxt.base.util.TimeSetUtils.getTimeSets(TimeSetUtils.java:32)	... 4 moreCaused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)	at java.lang.reflect.Constructor.newInstance(Unknown Source)	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)	at com.mysql.jdbc.MysqlIO.(MysqlIO.java:346)	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334)	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)	at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:794)	at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)	at java.lang.reflect.Constructor.newInstance(Unknown Source)	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)	at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)	at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)	... 7 moreCaused by: java.net.ConnectException: Connection refused: connect	at java.net.PlainSocketImpl.socketConnect(Native Method)	at java.net.PlainSocketImpl.doConnect(Unknown Source)	at java.net.PlainSocketImpl.connectToAddress(Unknown Source)	at java.net.PlainSocketImpl.connect(Unknown Source)	at java.net.SocksSocketImpl.connect(Unknown Source)	at java.net.Socket.connect(Unknown Source)	at java.net.Socket.connect(Unknown Source)	at java.net.Socket.(Unknown Source)	at java.net.Socket.(Unknown Source)	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)	at com.mysql.jdbc.MysqlIO.(MysqlIO.java:295)	... 23 more2012-2-19 15:35:27 edu.gzucm.yjsglxt.base.util.InitInfoUtil 严重: nullorg.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)	at edu.gzucm.yjsglxt.base.util.DataSourceUtil.getConnection(DataSourceUtil.java:67)	at edu.gzucm.yjsglxt.base.util.InitInfoUtil.(InitInfoUtil.java:265)	at edu.gzucm.yjsglxt.base.filter.PrepareFilter.init(PrepareFilter.java:116)	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)	at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:98)	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4584)	at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5262)	at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5257)	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)	at java.util.concurrent.FutureTask.run(Unknown Source)	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)	at java.lang.Thread.run(Unknown Source)Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)	at java.lang.reflect.Constructor.newInstance(Unknown Source)	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)	at com.mysql.jdbc.MysqlIO.(MysqlIO.java:346)	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334)	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)	at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:794)	at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)	at java.lang.reflect.Constructor.newInstance(Unknown Source)	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)	at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)	at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)	... 17 moreCaused by: java.net.ConnectException: Connection refused: connect	at java.net.PlainSocketImpl.socketConnect(Native Method)	at java.net.PlainSocketImpl.doConnect(Unknown Source)	at java.net.PlainSocketImpl.connectToAddress(Unknown Source)	at java.net.PlainSocketImpl.connect(Unknown Source)	at java.net.SocksSocketImpl.connect(Unknown Source)	at java.net.Socket.connect(Unknown Source)	at java.net.Socket.connect(Unknown Source)	at java.net.Socket.(Unknown Source)	at java.net.Socket.(Unknown Source)	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)	at com.mysql.jdbc.MysqlIO.(MysqlIO.java:295)	... 33 more2012-2-19 15:35:27 org.apache.coyote.AbstractProtocol start信息: Starting ProtocolHandler ["http-bio-8080"]2012-2-19 15:35:27 org.apache.coyote.AbstractProtocol start信息: Starting ProtocolHandler ["ajp-bio-8009"]2012-2-19 15:35:27 org.apache.catalina.startup.Catalina start信息: Server startup in 2983 ms

我知道是连接数据库的时候出现了错误,我检查了我的tomcat的配置文件context.xml文件

配置如下:

 1 
2 3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 -->
18
19
20 WEB-INF/web.xml
21
22
23 24
25 -->
26
27 28 on session expiration as well as webapp lifecycle) -->
29 30
31 -->
32 33 driverClassName="com.mysql.jdbc.Driver"
34 maxActive="100"
35 maxIdle="30"
36 maxWait="10000"
37 name="jdbc/mysql"
38 password="root"
39 type="javax.sql.DataSource"
40 url="jdbc:mysql:///yjsglxt?characterEncoding=UTF-8"
41 username="root"/>
42

查了一下,才发现原来是url这里有问题:

1 url="jdbc:mysql:///yjsglxt?characterEncoding=UTF-8" 

应该改成:

1 url="jdbc:mysql://localhost:3306/yjsglxt?characterEncoding=UTF-8" 

这样做了以后,再次运行一下项目,嘿嘿,可以了……………………bitsCN.com

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

CannotcreatePoolableConnectionFactory(Communicationslink_MySQL

CannotcreatePoolableConnectionFactory(Communicationslink_MySQL:bitsCN.com 今天在做web项目的时候碰到了这样的一个异常:Caused by: java.lang.RuntimeException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communic
推荐度:
标签: 今天 mysql connection
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top