dao出错,好像无法连接数据库

来源:2-7 验证Dao

AKIRA_ZZH

2019-04-15

四月 15, 2019 4:19:44 下午 org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
四月 15, 2019 4:19:44 下午 org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
信息: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@1e67b872, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@60addb54, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@3f2a3a5, org.springframework.test.context.support.DirtiesContextTestExecutionListener@4cb2c100, org.springframework.test.context.transaction.TransactionalTestExecutionListener@6fb554cc, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@614c5515]
四月 15, 2019 4:19:44 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/spring-dao.xml]
四月 15, 2019 4:19:44 下午 org.springframework.context.support.GenericApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.GenericApplicationContext@7dc7cbad: startup date [Mon Apr 15 16:19:44 CST 2019]; root of context hierarchy
四月 15, 2019 4:19:44 下午 com.mchange.v2.log.MLog
信息: MLog clients using java 1.4+ standard logging.
四月 15, 2019 4:19:44 下午 com.mchange.v2.c3p0.C3P0Registry banner
信息: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

The error may exist in file [D:\workplace\o2o\target\classes\mapper\AreaDao.xml]

The error may involve com.zzh.o2o.dao.AreaDao.queryArea

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

请教下老师该怎么更正

写回答

3回答

翔仔

2019-04-16

同学好,我感觉是你用了mysql8而用的是mysql5的驱动。建议在没有类似解决问题的能力之前,还是先用目前市面依然主流的mysql5.x,否则要把c3p0和相关数据库jdbc版本调整到最新,并且后续mysql8在主从同步的grant语句语法也不一样

0
3
翔仔
回复
AKIRA_ZZH
赞同学解决问题的能力,我视频里用的是mysql5.7.18的版本
2019-04-16
共3条回复

AKIRA_ZZH

提问者

2019-04-15

我觉得有可能是我的spring-dao.xml中的配置出了问题

0
0

AKIRA_ZZH

提问者

2019-04-15

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: Connections could not be acquired from the underlying database!

### The error may exist in file [D:\workplace\o2o\target\classes\mapper\AreaDao.xml]

### The error may involve com.zzh.o2o.dao.AreaDao.queryArea

### The error occurred while executing a query

### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

这个是错误测试的报告,我认为应该是数据库没有连接成功,但是我也不知道哪里出了错误

0
1
qq_慕少2290290
你好我是mysql版本是:Server version: 5.7.28-log MySQL Community Server (GPL) 我按照你改了加了cj和修改的pom还是不行。。你说spring-dao的问题是什么问题呢?
2020-05-12
共1条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5127 学习 · 8148 问题

查看课程