gpt4 book ai didi

java.sql.SQLException : HikariDataSource HikariDataSource (HikariPool-1) has been closed

转载 作者:行者123 更新时间:2023-12-04 12:58:00 50 4
gpt4 key购买 nike

Exception in thread "task-2" org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.我有一个 SQL 脚本,它只是在应用程序启动时插入一些记录spring.datasource.data=classpath:kana.sql它似乎运行了大约 10-20 就好了然后突然就退出了
我的 application.properties :

## default connection pool
spring.datasource.hikari.connectionTimeout=20000
spring.datasource.hikari.maximumPoolSize=5

spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create

## PostgreSQL
spring.datasource.url=jdbc:postgresql://10.0.0.100:5432/langsite
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.driverClassName=org.postgresql.Driver

spring.datasource.initialization-mode=always
spring.datasource.data=classpath:kana.sql

server.port=4000

#drop n create table again, good for testing, comment this in production
# javax.persistence.schema-generation.scripts.action=create
# javax.persistence.schema-generation.create-source=metadata
# javax.persistence.schema-generation.drop-source=metadata

它最初似乎连接成功,因为它可以创建表,插入一些记录,但是在插入过程中它只是胡说八道。

最佳答案

看起来您的应用程序用尽了池中的可用连接。
我想这两件事是矛盾的:
这个

spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create
和这个
spring.datasource.initialization-mode=always
spring.datasource.data=classpath:kana.sql
如果您想通过 Hibernate 创建模式,请尝试使用此选项来加载初始数据
spring.jpa.properties.hibernate.hbm2ddl.import_files=classpath:kana.sql
无论如何引用这篇文章。它应该有帮助
https://dimitr.im/loading-initial-data-with-spring

关于java.sql.SQLException : HikariDataSource HikariDataSource (HikariPool-1) has been closed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63855444/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com