Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection问题排查

一,我用的数据库访问错误

### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure



The last packet successfully received from the server was 19,126 milliseconds ago.  The last packet sent successfully to the server was 19,126 milliseconds ago.)
### The error may exist in file [D:\software\apache-tomcat-7.0.70\webapps\ROOT\WEB-INF\classes\com.hcmony.mapper\UserMapper.xml]
### The error may involve com.hcmony.mapper.UserMapper.findById
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure


The last packet successfully received from the server was 19,126 milliseconds ago.  The last packet sent successfully to the server was 19,126 milliseconds ago.)] with root cause
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:170)

at java.net.SocketInputStream.read(SocketInputStream.java:141)


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure

The last packet successfully received from the server was 19,120 milliseconds ago.  The last packet sent successfully to the server was 19,119 milliseconds ago.)
### The error may exist in file [D:\software\apache-tomcat-7.0.70\webapps\ROOT\WEB-INF\classes\com.hcmony.mapper\UserMapper.xml]
### The error may involve com.hcmony.mapper.UserMapper.findById
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure

The last packet successfully received from the server was 19,120 milliseconds ago.  The last packet sent successfully to the server was 19,119 milliseconds ago.)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:980)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

root cause



主要问题有几个:

1,配置文件写错,比如是某个字母写错了,或者漏掉了,

如<property name="driverClassName" value="com.mysql.jdbc.Driver"/>

写成<property name="driverClassName" value="com.mysql.jdbc.Drivar"/>之类的,

还有其它url,用户名,密码之类的,多找找。

2,网络不通导致的.因为是在远程需要vpn. 碰到此问题可以先检查下网络

我碰到的就这个问题,换成本地就好了。

3,缺少jar包导致的。

<!-- 导入Mysql数据库链接jar-->
<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.36</version>
</dependency>
<!-- 导入dbcp2jar包,用来在applicationContext.xml中配置数据库 -->
<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-dbcp2</artifactId>
  <version>2.1.1</version>
</dependency>





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值