简体   繁体   English

无法创建池的初始连接,无法获取 JDBC 连接错误

[英]Unable to create initial connections of pool, Unable to obtain JDBC Connection errors

I have a Spring Boot data JPA application where I am creating two data sources.我有一个 Spring Boot 数据 JPA 应用程序,我在其中创建了两个数据源。 I am getting this error when my application is booting up.我的应用程序启动时出现此错误。

1. org.apache.tomcat.jdbc.pool.ConnectionPool init
SEVERE: Unable to create initial connections of pool.
java.sql.SQLException
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:253)
2. Caused by: java.lang.NullPointerException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:245)
    ... 88 more

3. Jan 20, 2020 7:39:29 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: null
[http-bio-8080-exec-1] ERROR org.springframework.boot.web.support.ErrorPageFilter - Forwarding to error page from request [/orderForDateTopK/1/2] due to exception [Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection]
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
    at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:431)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)

4. Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)

5. Caused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection

You're using Tomcat JDBC Connection Pool for your datasource, but in your application.properties you configured connection pool for Hikari datasource.您正在为您的数据源使用Tomcat JDBC 连接池,但在您的application.properties中,您为Hikari数据源配置了连接池

Your datasource is not instanced well, because of the connection pool settings.由于连接池设置,您的datasource没有很好地实例化。

your wrong configuration:你的错误配置:

#HikariCP settings
spring.datasource.hikari.connection-timeout=60000
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.minimum-idle=1

You have 2 solutions你有2个解决方案

1- Change your connection pool settings from hikari to tomcat 1- 将连接池设置从 hikari 更改为 tomcat

like so像这样

spring.datasource.tomcat.initial-size=
spring.datasource.tomcat.max-wait=
spring.datasource.tomcat.max-active=
spring.datasource.tomcat.max-idle=
spring.datasource.tomcat.min-idle=
spring.datasource.tomcat.default-auto-commit=
//..

Some useful guide in this field:该领域的一些有用指南:

Configuring a Tomcat Connection Pool 配置 Tomcat 连接池

2- Use Hikari Connection Pool instead of tomcat (Change datasource connection pool) 2- 使用Hikari 连接池而不是tomcat (更改数据源连接池)

Some useful guide in this field:该领域的一些有用指南:

A Simple Guide to Connection Pooling in Java Java 连接池的简单指南

Introduction to HikariCP HikariCP简介

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SpringBoot MySQL JDBC 无法创建池的初始连接 - SpringBoot MySQL JDBC Unable to create initial connections of pool org.apache.tomcat.jdbc.pool.ConnectionPool-无法使用yml文件创建池的初始连接 - org.apache.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool with yml file oatomcat.jdbc.pool.ConnectionPool:无法创建池的初始连接。 春季启动+ MySql - o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool. Spring Boot + MySql org.apache.tomcat.jdbc.pool.ConnectionPool - 无法创建池的初始连接 - org.apache.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool 无法在springboot中创建初始连接池 - Unable to create initial pool of connections in springboot 无法创建池异步Jersey + Spring + Tomcat的初始连接 - Unable to create initial connections of pool Async Jersey+Spring+Tomcat 启动期间出现Java错误“无法创建池的初始连接” - Java Error 'Unable to create initial connections of pool' during startup 如何解决无法获得孤立的JDBC连接的问题? - How to resolve unable to obtain isolated JDBC connection? 严重:无法使用context.xml文件创建pool-tomcat 7的初始连接 - SEVERE: Unable to create initial connections of pool - tomcat 7 with context.xml file Docker Compose-Flyway-无法从数据源获取Jdbc连接 - Docker Compose - Flyway - Unable to obtain Jdbc connection from DataSource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM