본문 바로가기
오류 해결

[JDBC] BadSqlGrammarException

by 쿠쿠씨 2022. 5. 3.
반응형

 

오류 메시지

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:

 

상황

insert문을 실행시키는 중 컬럼명이 달라서 오류가 발생했습니다.

<insert id="insertNotice" parameterType="Notice">
	INSERT INTO notice (notice_idx,notice_title,notice_contents)
	VALUES (notice_idx_seq.nextval,#{notice_title},#{notice_contents})
</insert>

 

원인

1) 매퍼 xml 파일에서 SQL 구문의 컬럼명이 DB 테이블의 컬럼명과 다른 경우

2) 값을 받아올 때 #{ } 대신 ${ }을 작성한 경우

 

 

해결 방법

1) SQL문을 DB테이블의 컬럼명으로 작성했는지 확인합니다.

2) 값을 받을 때 #{ }로 받았는지 확인합니다.

<insert id="insertNotice" parameterType="Notice">
	INSERT INTO notice (notice_idx,notice_title,notice_content)
	VALUES (notice_idx_seq.nextval,#{notice_title},#{notice_content})
</insert>
반응형

댓글