无法打开 JPA EntityManager 进行事务;嵌套异常是 org.hibernate.exception.JDBCConnectionException

问题描述 投票:0回答:1

我有一个 Spring Boot 项目。我在Intellij IDE上运行是没问题的。我没有收到任何错误。当我部署到 tomcat 服务器时,它正在运行,但是当我尝试连接数据库时,出现错误。错误描述如下:

    Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection-

我认为 Tomcat 无法使用此属性连接到数据库。

我的应用程序属性是:

spring.datasource.jdbcUrl=jdbc:sqlserver://localhost;databaseName=IDDAA
spring.datasource.username=IDDAA
spring.datasource.password=awedrtgh0349
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.hikari.connection-timeout=10000
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=15
spring.datasource.hikari.pool-name=HikariConnectionPool
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
#spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServerDialect
#spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2014Dialect
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
hibernate.hbm2ddl.auto=update

我尝试更改 application.properties 但什么也没得到。

java spring-boot hibernate tomcat spring-data-jpa
1个回答
0
投票

您是否尝试过更改最大池大小=10。

例如,有一次我使用 pgAdmin,它占用了 25 个位置。也许你也有类似的东西 ́_(ツ)_/́.

澄清您在 app.properties 中到底更改了什么也很好

© www.soinside.com 2019 - 2024. All rights reserved.