The project database source uses druid
When the project starts, an error is reported when connecting to the database: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"
That is, there are too many connections;
Solution: temporarily change the number of database connections to a smaller value
specific method:
<bean id="baseDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
........
<!-- Configure initialization size, minimum, maximum -->
<property name="initialSize" value="3" />
<property name="minIdle" value="3" />
<property name="maxActive" value="3" />
........
Modify the value of maxActive to a smaller number, such as 3, and restart the project;
We understand the specific meaning of the following configuration:
initialSize | 0 | The number of physical connections established during initialization. Initialization occurs when the init method is explicitly called, or the first time getConnection |
maxActive | 8 | Maximum number of connection pools |
maxIdle | 8 | It is no longer used, and the configuration has no effect |
minIdle | Minimum number of connection pools | |
maxWait | The maximum wait time when getting a connection, in milliseconds. After configuring maxWait, fair lock is enabled by default, and the concurrency efficiency will decrease. If necessary, you can configure useUnfairLock |