当前位置:网站首页>Error getting a new connection Cause: org. apache. commons. dbcp. SQLNestedException
Error getting a new connection Cause: org. apache. commons. dbcp. SQLNestedException
2022-07-06 06:22:00 【Do not let it rot】
Problem description
Use today Acitivity establish ProcessEngineConfiguration The object is wrong
Error is as follows
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
### Error getting a new connection. Cause: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
### Cause: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
To analyze problems
1 It could be mysql Version driven problems
2 There may be a configuration error
3 I tested and inquired about the relevant errors on the Internet , Most of the reasons are mysql Version problem or configuration error , such as url Exact parameters , drive 8.0 Less cj, I am because of the version problem , I'm a local 8.0 The database of , however jar yes 5.7 Of
solve the problem
The relevant code is as follows
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wyh</groupId>
<artifactId>Activiti01</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<activiti.version>6.0.0</activiti.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-rest-api</artifactId>
<version>${
activiti.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
To configure
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/contex
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!--dbcp Link pool -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql:///activiti?serverTimezone=UTC"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
<property name="maxActive" value="3"/>
<property name="maxIdle" value="1"/>
</bean>
<!-- By default bean Of id Fixed for processEngineConfiguration-->
<bean id="processEngineConfiguration"
class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- Configuration database related information -->
<!-- Database driven
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>-->
<!-- Database link
<property name="jdbcUrl" value="jdbc:mysql:///activiti"/>-->
<!-- Database user name
<property name="jdbcUsername" value="root"/>-->
<!-- Database password
<property name="jdbcPassword" value="123456"/>-->
<!-- Directly reference the link pool configured above -->
<property name="dataSource" ref="dataSource"/>
<!--actviti Strategy of database table generation
true - If the corresponding table already exists in the database , So use... Directly ,
If it doesn't exist , So it will create -->
<property name="databaseSchemaUpdate" value="true"/>
</bean>
</beans>
Test class
package com.wyh.test;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.junit.Test;
/** * @program: Activiti01 * @description: * @author: Wei Yihe * @createDate: 2022-06-22 21:59 **/
public class TestCreateTable {
/** * Use activiti Provides the default way to create mysql Table of */
@Test
public void testCreateDbTable(){
// Need to use avtiviti Tool class provided ProcessEngines , Usage method getDefaultProcessEngine
// getDefaultProcessEngine Will default from resources The next read name is actviti.cfg.xml The file of
// establish processEngine when , Will be created mysql Table of
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
System.out.println(processEngine);
}
}
Start the test again after modification
You can see that the log information is already creating tables
view the database The table has been created normally
边栏推荐
- D - How Many Answers Are Wrong
- Isam2 and incrementalfixedlagsmooth instructions in gtsam
- JWT-JSON WEB TOKEN
- Simulation volume leetcode [general] 1447 Simplest fraction
- 「 WEB测试工程师 」岗位一面总结
- Simulation volume leetcode [general] 1249 Remove invalid parentheses
- selenium源码通读·9 |DesiredCapabilities类分析
- RestTemplate、Feign实现Token传递
- 二维码的前世今生 与 六大测试点梳理
- Testing of web interface elements
猜你喜欢
Full link voltage measurement: building three models
Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
E - 食物链
The latest 2022 review of "graph classification research"
Pat (Grade B) 2022 summer exam
JWT-JSON WEB TOKEN
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Delete the variables added to watch1 in keil MDK
G - Supermarket
ICLR 2022 spotlight | analog transformer: time series anomaly detection method based on correlation difference
随机推荐
基于JEECG-BOOT制作“左树右表”交互页面
Simulation volume leetcode [general] 1218 Longest definite difference subsequence
基于JEECG-BOOT的list页面的地址栏参数传递
Avtiviti创建表时报错:Error getting a new connection. Cause: org.apache.commons.dbcp.SQLNestedException
【Postman】Monitors 监测API可定时周期运行
php使用redis实现分布式锁
JDBC requset corresponding content and function introduction
LeetCode 1200. 最小绝对差
Simulation volume leetcode [general] 1143 Longest common subsequence
模拟卷Leetcode【普通】1109. 航班预订统计
Redis 核心技术与实战之 基本架构:一个键值数据库包含什么?
Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
leaflet 地图
模拟卷Leetcode【普通】1296. 划分数组为连续数字的集合
Selenium source code read through · 9 | desiredcapabilities class analysis
职场进阶指南:大厂人必看书籍推荐
Simulation volume leetcode [general] 1219 Golden Miner
联合索引的左匹配原则
黑猫带你学UFS协议第4篇:UFS协议栈详解
模拟卷Leetcode【普通】1219. 黄金矿工