แมลงสาบ Db พร้อมสปริงบูท

ขณะใช้ Coacroach Db กับ Spring Boot และ Spring Batch ฉันได้รับข้อผิดพลาดต่อไปนี้

org.postgresql.util.PSQLException: ERROR: invalid value for parameter "TimeZone": "Europe/London"

รายละเอียด: ระบบไม่พบเส้นทางที่ระบุ

Application.properties

spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect
spring.datasource.username=root
spring.datasource.password=
spring.datasource.type=com.zaxxer.hikari.HikariDataSource

spring.datasource.url=jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable&serverTimezone=UTC&useLegacyDatetimeCode=false

spring.jpa.properties.hibernate.jdbc.time_zone= UTC

spring.batch.initialize-schema = always

ฉันยังเพิ่มคุณสมบัตินี้และคุณสมบัติข้างต้นตามที่กล่าวไว้บางแห่ง แต่ก็ไม่ได้ช่วยอะไร

@PostConstruct
void started() {
  TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}

person Chandresh Mishra    schedule 06.05.2020    source แหล่งที่มา


คำตอบ (2)


ด้วยความอยากรู้ว่าคุณใช้ระบบปฏิบัติการใดอยู่? เรามีปัญหาแบบเปิดที่เกี่ยวข้องกับเขตเวลา ซึ่งทราบกันว่าส่งผลต่อ Windows

เมื่อคุณระบุเขตเวลา UTC คุณได้รับข้อผิดพลาดเดียวกันกับที่คุณทำกับ "ยุโรป/ลอนดอน" หรือไม่ จะเป็นอย่างไรหากคุณลองใช้ออฟเซ็ตตัวเลข เช่น "+0:00"

นอกจากนี้ เมื่อตั้งค่าเขตเวลาผ่าน URL พารามิเตอร์ควรเป็น timezone=utc (หรือค่าอื่นใดที่คุณต้องการ)

person rafiss    schedule 13.05.2020
comment
ใช่ ฉันใช้เครื่อง windows จะตั้งค่าผ่าน URL ได้อย่างไร? - person Chandresh Mishra; 14.05.2020
comment
ลองใช้ URL นี้: jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable&timezone=UTC - person rafiss; 14.05.2020

เลยเห็นประเด็นต่างๆ มากมาย

1.  You said you are using Coacroach Db but you seem to be loading a JDBC JAR and ULR string for Postgres.  

2.  Posgres does not have "Europe/London" as a valid TimeZone String.  There is a "Europe/London GB GB-Eire" 
See: https://www.postgresql.org/docs/8.1/datetime-keywords.html

3.  You have a space in the time zone property name.
    This:       spring.jpa.properties.hibernate.jdbc.time_zone= UTC
    Should Be:  spring.jpa.properties.hibernate.jdbc.time_zone=UTC
person BrianC    schedule 08.05.2020
comment
1) URL ที่ถูกต้องควรเป็นอย่างไร 2) ฉันยังไม่ได้กำหนดเขตเวลายุโรป/ลอนดอน ไม่แน่ใจว่าจะไปที่ไหน 3) พื้นที่ไม่สามารถแก้ปัญหาได้ - person Chandresh Mishra; 10.05.2020
comment
URL ของฐานข้อมูลจะเป็นสิ่งที่คุณเท่านั้นที่จะรู้ แต่ถ้าเป็น CoacroachDB อย่างที่คุณพูด URL ก็ไม่ควรมี Posgres อยู่ในนั้น jdbc:postgresql://localhost และไม่ควรใช้ไดรเวอร์ Postgres org.postgresql.Driver - person BrianC; 11.05.2020
comment
ไม่มีไดรเวอร์สำหรับแมลงสาบ db - person Chandresh Mishra; 12.05.2020
comment
ไม่มีไดรเวอร์ JDBC เลยเหรอ? ถ้าอย่างนั้นคุณจะไม่สามารถใช้มันใน Java ได้ ดังนั้นฉันสงสัยว่าเป็นเช่นนั้น ไม่ว่าจะด้วยวิธีใดก็ตามการรู้ว่าใช้ผิดจะไม่ได้ผลดี - person BrianC; 13.05.2020
comment
@BrianC CockroachDB สามารถใช้งานร่วมกับ Postgres ได้ @ChandreshMishra ถูกต้องในการใช้ไดรเวอร์ PGJDBC และ URL ที่มีส่วนนำหน้า postgresql เรามีบทช่วยสอนที่นี่เพื่อเริ่มต้นใช้งาน CockroachDB และ Spring Boot (ข้อจำกัดความรับผิดชอบ: ฉันทำงานกับ CockroachDB) cockroachlabs.com/blog/tutorial-spring- ไฮเบอร์เนต - person rafiss; 13.05.2020