CouldnotgetJDBCConnection异常问题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
CouldnotgetJDBCConnection异常问题
此异常发⽣在整合SSM过程中.
数据库的properties⽂件中⽤户名的关键词写成了username, 导致报错⽆法连接
db.properties⽂件如下:
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql:///how2java?serverTimezone=GMT
username=root
password=admin
配置⽂件如下
<bean id="dataSource"class="boPooledDataSource">
<property name="driverClass" value="${driver}"/>
<property name="jdbcUrl" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</bean>
异常情况如下:
### 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 databas ### The error may exist in file [C:\Users\Tongc\IdeaProjects\ssm_myself\target\classes\mapper\CategoryMapper.xml]
### The error may involve com.cugb.mapper.CategoryMapper.get
### 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!
通过⽹上查找得知:
当出现上⾯的Exception,⽽且spring的配置⽂件如上⾯两个⽂件所⽰时,⽆法连接数据库的原因在于。