개발일지/SPRING
[에러] Cannot invoke "org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(java.sql.SQLException, String)"
양쏘쏘
2024. 7. 9. 15:37
728x90
반응형
스프링부트에서 MySQL을 세팅하다가 에러가 발생했다.
1. 상황 설명
// build.gradle
runtimeOnly 'com.mysql:mysql-connector-j'
//application.yml
spring:
datasource:
url: jdbc:mysql://localhost:3306/database
username: username
password: password
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto=update:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
Gradle 세팅이나 데이터베이스 설정 정보는 문제가 없었는데 연결이 안되고 에러가 발생했다.
2. 해결방법
다른 곳의 문제가 아닌 연결을 시도한 mysql 계정의 권한 문제였다.
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP ON your_database.* TO 'new_user'@'localhost';
FLUSH PRIVILEGES;
[참고자료]
https://spring.io/guides/gs/accessing-data-mysql
Getting Started | Accessing data with MySQL
To package and run the application, we need to provide an external MySQL database rather than using Spring Boot Docker Compose Support. For this task, we can reuse the provided compose.yaml file with a few modifications: First, modify the ports entry in co
spring.io
728x90