CannotcreatePoolableConnectionFactory (Communicationslink_MySQL

Source: Internet
Author: User
CannotcreatePoolableConnectionFactory (Communicationslinkfailure) -- Connectionrefused: connect bitsCN.com

Today, when I was working on a web project, I encountered such an exception:

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 attached ed any packets from the server .) at edu.gz ucm. yjsglxt. base. util. timeSetUtils. getTimeSets (TimeSetUtils. java: 52) at edu.gz ucm. 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 attached ed 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.gz ucm. 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 attached ed 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: connectat 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.gz ucm. yjsglxt. base. util. InitInfoUtil
        
          Severe: 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 attached ed 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.gz ucm. yjsglxt. base. util. dataSourceUtil. getConnection (performanceutil. java: 67) at edu.gz ucm. yjsglxt. base. util. initInfoUtil.
         
           (InitInfoUtil. java: 265) at edu.gz ucm. 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 attached ed 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: connectat 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 Information: Starting ProtocolHandler ["http-bio-8080"] 15:35:27 org. apache. coyote. abstractProtocol start Information: Starting ProtocolHandler ["ajp-bio-8009"] 15:35:27 org. apache. catalina. startup. catalina start Information: Server startup in 2983 MS
                
               
              
             
            
           
          
         
        
       
      
     
    
   
  
 

I know an error occurred while connecting to the database. I checked the context. xml file of my tomcat configuration file.

The configuration is as follows:

 1 
 
2
18
19
20 WEB-INF/web.xml
21
22
23
26
27
29
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

After checking this information, we found that the original url has a problem:

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

It should be changed:

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

After doing so, run the project again ........................

BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.