Could not get JDBC Connection--java

Source: Internet
Author: User

Postman on the call contract service, background run error, as follows:

{    "Timestamp": 1536203887641,    "Status": 500,    "Error": "Internal Server Error",    "Exception": "Org.mybatis.spring.MyBatisSystemException",    "Message": "Nested exception is org.apache.ibatis.exceptions.PersistenceException: \n### Error querying database.Cause:org.springframework.jdbc.CannotGetJdbcConnectionException:Could not get JDBC Connection; Nested exception is org.apache.commons.dbcp.SQLNestedException:Cannot create Poolableconnectionfactory ( Communications Link failure\n\nthe Last packet sent successfully to the server was 0 milliseconds ago. The driver has no received any packets from the server.) \n### the error may exist in file [/users/lizhao/documents/code/retail-seal/seal-server/target/classes/mappers/ contracttemplatedetailmapper.xml]\n### the error may involve tech.fullink.stone.seal.server.dao.mappers.contracttemplatedetailmapper.selectbycontractcode\n### the error occurred while executing a query\n### Cause:org.springframework.jdbc.CannotGetJdbcConnectionException:Could not get JDBC Connection; Nested exception is org.apache.commons.dbcp.SQLNestedException:Cannot create Poolableconnectionfactory ( Communications Link failure\n\nthe Last packet sent successfully to the server was 0 milliseconds ago. The driver has no received any packets from the server.) ",    "Path": "/retail-seal/api/v1/seal"}

Online for "jdbc." After cannotgetjdbcconnectionexception:could not get JDBC Connection keyword search, it was found that it did not match the current situation. Carefully check the various configurations of the database connection and find the accuracy.

In the absence of a solution, write unit Tests against query statements, and find different error hints:

# # # Cause:org.springframework.jdbc.CannotGetJdbcConnectionException:Could not get JDBC Connection; nested Exception is org.apache.commons.dbcp.SQLNestedException:Cannot create Poolableconnectionfactory (Communications link Failurethe last packet sent successfully to the server was0milliseconds ago.    The driver has no received any packets from the server.) At Org.apache.ibatis.exceptions.ExceptionFactory.wrapException (Exceptionfactory.java:30) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (Defaultsqlsession.java:150) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (Defaultsqlsession.java:141) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne (Defaultsqlsession.java:77) 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.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (Sqlsessiontemplate.java:433)    ... 40morecaused by:org.springframework.jdbc.CannotGetJdbcConnectionException:Could not get JDBC Connection; nested Exception is org.apache.commons.dbcp.SQLNestedException:Cannot create Poolableconnectionfactory (Communications link Failurethe last packet sent successfully to the server was0milliseconds ago.    The driver has no received any packets from the server.) At Org.springframework.jdbc.datasource.DataSourceUtils.getConnection (Datasourceutils.java:80) at Org.mybatis.spring.transaction.SpringManagedTransaction.openConnection (Springmanagedtransaction.java: 82) at Org.mybatis.spring.transaction.SpringManagedTransaction.getConnection (Springmanagedtransaction.java: 68) at Org.apache.ibatis.executor.BaseExecutor.getConnection (Baseexecutor.java:338) at Org.apache.ibatis.executor.SimpleExecutor.prepareStatement (Simpleexecutor.java:84) at Org.apache.ibatis.executor.SimpleExecutor.doQuery (Simpleexecutor.java:62) at Org.apache.ibatis.executor.BaseExecutor.queryFromDatabase (Baseexecutor.java:326) at Org.apache.ibatis.executor.BaseExecutor.query (Baseexecutor.java:156) at Org.apache.ibatis.executor.CachingExecutor.query (Cachingexecutor.java:109) at Org.apache.ibatis.executor.CachingExecutor.query (Cachingexecutor.java:83) 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.apache.ibatis.plugin.Invocation.proceed (Invocation.java:49) at Com.github.pagehelper.sqlutil._processpage (Sqlutil.java:401) at Com.github.pagehelper.SqlUtil.processPage (Sqlutil.java:374) at Com.github.pagehelper.PageHelper.intercept (Pagehelper.java:254) at Org.apache.ibatis.plugin.Plugin.invoke (Plugin.java:61) at Com.sun.proxy. $Proxy 140.query (Unknown Source) at Org.apache.ibatis.session.defaults.DefaultSqlSession.sele Ctlist (Defaultsqlsession.java:148)    ... 47morecaused by:org.apache.commons.dbcp.SQLNestedException:Cannot Create poolableconnectionfactory ( Communications Link failurethe Last packet sent successfully to the server was0milliseconds ago.    The driver has no received any packets from the server.) At Org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory (Basicdatasource.java:1549) at Org.apache.commons.dbcp.BasicDataSource.createDataSource (Basicdatasource.java:1388) at Org.apache.commons.dbcp.BasicDataSource.getConnection (Basicdatasource.java:1044) at Org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection (Datasourceutils.java:111) at Org.springframework.jdbc.datasource.DataSourceUtils.getConnection (Datasourceutils.java:77)    ... 67morecaused by:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications Link failurethe last Packet sent successfully to the server was0milliseconds ago.    The driver has no received any packets from the server. At Sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method) at Sun.reflect.NativeConstructorAccessorImpl.newInstance (Nativeconstructoraccessorimpl.java:62) at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (Delegatingconstructoraccessorimpl.java:45) at Java.lang.reflect.Constructor.newInstance (Constructor.java:423) at Com.mysql.jdbc.Util.handleNewInstance (Util.java:408) at Com.mysql.jdbc.SQLError.createCommunicationsException (Sqlerror.java:1137) at Com.mysql.jdbc.MysqlIO.<init> (mysqlio.java:356) at Com.mysql.jdbc.ConnectionImpl.coreConnect (Connectionimpl.java:2504) at Com.mysql.jdbc.ConnectionImpl.connectOneTryOnly (Connectionimpl.java:2541) at Com.mysql.jdbc.ConnectionImpl.createNewIO (Connectionimpl.java:2323) at Com.mysql.jdbc.ConnectionImpl.<init> (connectionimpl.java:832) at com.mysql.jdbc.JDBC4Connection.<init> (jdbc4connection.java:46) at Sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method) at Sun.reflect.NativeConstructorAcce Ssorimpl.newinstance (Nativeconstructoraccessorimpl.java:62) at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (Delegatingconstructoraccessorimpl.java:45) at Java.lang.reflect.Constructor.newInstance (Constructor.java:423) at Com.mysql.jdbc.Util.handleNewInstance (Util.java:408) at Com.mysql.jdbc.ConnectionImpl.getInstance (Connectionimpl.java:417) at Com.mysql.jdbc.NonRegisteringDriver.connect (Nonregisteringdriver.java:344) at Org.apache.commons.dbcp.DriverConnectionFactory.createConnection (Driverconnectionfactory.java:38) at Org.apache.commons.dbcp.PoolableConnectionFactory.makeObject (Poolableconnectionfactory.java:582) at Org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory (Basicdatasource.java:1556) at Org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory (Basicdatasource.java:1545)    ... 71morecaused by: java.net.UnknownHostException: Saas.database:nodename nor servname provided, or not known At Java.net.Inet6AddressImpl.lookupAllHostAddr (Native Method) at java.net.inetaddress$2.LOOKUPALLHOSTADDR (inetaddress.java:928) at Java.net.InetAddress.getAddressesFromNameService (Inetaddress.java:1323) at JAVA.NET.INETADDRESS.GETALLBYNAME0 (Inetaddress.java:1276) at Java.net.InetAddress.getAllByName (Inetaddress.java:1192) at Java.net.InetAddress.getAllByName (Inetaddress.java:1126) at Com.mysql.jdbc.StandardSocketFactory.connect (Standardsocketfactory.java:250) at Com.mysql.jdbc.MysqlIO.<init> (mysqlio.java:306)    ... More

See the prompt immediately understand, because this service is modified by other services, the local configuration does not work, delete the cloud configuration OK.

Summary: Unit testing is important. Existing Service Transformation Services note the cloud configuration.

Could not get JDBC Connection--java

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.