Spring/Issue

[오류 처리] could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement

블로그 주인장 2023. 10. 19.

could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement

Spring에서 JpaRespository를 이용하여 SQL을 사용할 때 발생하는 에러를 처리하는 방법을 알아보겠습니다.


오류 내용

  • o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1146, SQLState: 42S02
  • o.h.engine.jdbc.spi.SqlExceptionHelper   : Table 'project.diary' doesn't exist
  • could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement] with root cause

오류 처리 방안

  1. DB 테이블에 연결된 column과 IDE에서 선언한 객체들의 이름이 같은지 파악해야한다.
  2. IDE에서 @Entity로 생성했지만, DB 테이블을 생성하지 않은 경우 발생하기에, SQL 에서 생성이 되어있는지 파악해야한다.

인텔리제이(Intellj)
MySQL Bench

 

반응형

댓글