GoogleCloudPlatform / GoogleCloudPlatform/java-docs-samples

[Bug] JDBC URL connection using db_username instead of db_name for accessing DB

Đang mở
#8,650 1 bình luận 0 reaction 1 người được giao Được giao cho @gusthavosouza Xem trên GitHub
priority: p2 samples type: question
Ngôn ngữ chính
Java
Star
1.9k
Fork
2.9k
Merge trung bình
3 ngày 3 giờ
Pull request đã merge (30 ngày)
17

Mô tả

Hey, I am setting up an application on Google Cloud tech stack:

GCP SQL Postgress 15
Spring JPA 3.0.1
Google App Engine

followed the examples on: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java

My configs:

```
spring:
cloud:
appId: my-app-id
datasource:
hikari:
data-source-properties:
socketFactory: "com.google.cloud.sql.postgres.SocketFactory"
cloudSqlInstance: ${INSTANCE_CONNECTION_NAME}
sslmode: disable
url: jdbc:postgresql://${DB_NAME}/
password: ${DB_PASSWORD}
username: ${DB_USERNAME}
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
gcp:
sql:
database-name: ${DB_NAME}
```

My app.yaml

```

runtime: java17
instance_class: F1
env_variables:
SPRING_PROFILES_ACTIVE: "prod"
INSTANCE_CONNECTION_NAME: postgress_connection_name
DB_NAME: db_name_anything
DB_USERNAME: db_user_anything
DB_PASSWORD: "_my_pass"
handlers:
- url: /.*
script: this field is required, but ignored
automatic_scaling:
min_idle_instances: automatic
max_idle_instances: 1
min_pending_latency: automatic
max_pending_latency: 0.030s
max_instances: 1

```

Error:

```

o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 3D000
2023-09-17 12:43:26 default[v1] 2023-09-17T12:43:26.201Z ERROR 12 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : FATAL: database "db_name_anything" does not exist
2023-09-17 12:43:26 default[v1] 2023-09-17T12:43:26.208Z ERROR 12 --- [ main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution [FATAL: database "db_name_anything" does not exist] [n/a]

```

I have solved the problem with creating the user as the name of the db, however, this seems like a bug to me.

Thank you!

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.