In my most recent job, I continue to develop apps with Spring-Boot. Every time I need to write DB connection settings in application.properties, I search on Google. I can find the article immediately, so it's okay, but I use it quite often, so I decided to leave it in my article. (Alas, maybe because of my age, I forget it immediately. Age doesn't matter ?!)
# MYSQL
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost/DB name
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.database=MYSQL #Optional when using JPA. Automatic judgment if not
spring.jpa.hibernate.ddl-auto=update
# PostgreSQL
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/DB name
spring.datasource.username=username
spring.datasource.password=password
Exception occurs when connecting with MyBatis. It is necessary to specify the time zone.
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: The server time zone value '???? (?W????)' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
spring.datasource.url=jdbc:mysql://localhost/DB name?serverTimezone=JST
References
-When connecting to MySQL, "java.sql.SQLException: The server time zone value" appears
Recommended Posts