gpt4 book ai didi

Spring,用于创建 ElephantSQL 表的 application.properties

转载 作者:行者123 更新时间:2023-11-29 13:19:52 24 4
gpt4 key购买 nike

我尝试进行部署(我使用 pivotal.io)。
在部署之前,我尝试为我的数据库创建表。在 pivotal.io 上,我创建了测试数据库 (ElephantSQL)。这个新数据库有:
共享高性能集群
20 MB 数据
4个并发连接

我使用 Spring,这在应用程序属性中描述了我的数据库。如果我在我的本地主机上创建数据库,这会起作用。`

spring.datasource.url=jdbc:postgresql://stampy.db.elephantsql.com:5432/iyraxwqa
spring.datasource.username=iyraxwqa
spring.datasource.password=*************************
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=create

spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=false`

当我运行我的应用程序时,我看到了这个错误:

2017-05-14 12:53:38.810 ERROR 4880 --- [           main] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

org.postgresql.util.PSQLException: FATAL: too many connections for role "iyraxwqa"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2586) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:113) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:222) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:215) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.Driver.makeConnection(Driver.java:404) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.Driver.connect(Driver.java:272) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.6.jar:na]
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.6.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:718) [tomcat-jdbc-8.5.6.jar:na]

我包含 hibernate h3p0 并添加此代码:

spring.jpa.properties.hibernate.c3p0.min_size = 1
spring.jpa.properties.hibernate.c3p0.max_size = 2
spring.jpa.properties.hibernate.c3p0.timeout = 300

但我看到了同样的错误。
如果我尝试手动创建一切正常,但我有很多表,半年前我用 spring 和 hibernate 创建了表
我的一张 table :

@Entity
@Table(name = "INTERIOR", schema = "public")
public class InteriorModel extends AllFinishProductModel {

@Column(name = "PHOTO")
private String photo;
@Column(name = "PHOTO01")
private String photo01;
@Column(name = "PHOTO02")
private String photo02;
@Id
@Column(name = "ID")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@Column
private String name;
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "COLOR")
private String color;
@Column(name = "QUANTITY")
private Double quantity;
@Column(name = "PRICE")
private BigDecimal price;
// getters and setters....

有人知道,我哪里错了吗?

最佳答案

我有同样的问题,我认为你使用的是免费计划(Tiny Turtle)。我认为问题在于 PosgreSql(elephantsql 服务器)支持的最大连接数,要了解最大连接数限制,您可以在 ElephantSql 浏览器中执行以下 sql 脚本:

select * from pg_roles where rolname='iyraxwqa'

它显示你在 postgresql 中的角色配置,你可以看到 'rolconnlimit' 列以了解支持的最大连接数

关于Spring,用于创建 ElephantSQL 表的 application.properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43962853/

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