Spring Boot

[Mybatis] Cause: java.sql.SQLException: 부적합한 열 유형: 1111

어코링 2024. 5. 26. 19:40

개인 프로젝트 도중

user CRUD C(insert)를 하고 있는 중

처음 보는 유형의 오류를 보게 되어서

오류 해결 과정을 기록해보겠다.

 

오류메세지

co.kr.fourteen.ese.user.controller.
EseUserController - EseUserVo(registNo=0, userId=null, userPw=null, tmprPwNo=null, userNm=null, userEmail=null, userPhone=null, userZipCode=null, userFirstAddr=null, userSecondAddr=null, userLevel=null, userDelYn=null, userDelDe=null, regDe=null, pwChangeDt=null, pwFailCnt=null, lastContactFmtDt=null, enabled=null, ipAddr=null, pwChgYn=null, idBlockYn=null, otpYn=null) - co.kr.fourteen.ese.user.controller.EseUserController.insertInfo(EseUserController.java:75) Loading class `com.mysql.jdbc.Driver'.
This is deprecated.
The new driver class is `com.mysql.cj.jdbc.Driver'.
The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. 2024-05-26 16:39:02,860 QUERY :: 1. PreparedStatement.setNull(1, 1111) java.sql.SQLException:
부적합한 열 유형: 1111

 

해결방법

GPT 괴롭다가 결국에는 구글링으로 해결했다.

 

<settings>
        <setting name="jdbcTypeForNull" value="NULL" />
</settings>

 

mybatis 설정 파일에 Null 처리를 하도록 명시하였다.

이렇게 설정하면 parameter mapping이 되지 않고 넘어가더라도 DB에 null로 값을 입력하게 된다.

 

 

한 가지 주의할 점은 <settings> 섹션 반드시 <typeAliases> 위에 입력해야 한다.

mybatis에서는 configuration xml에서 각 항목의 순서가 오류를 일으킬 수 있으니 확인하고 순서대로 입력해야 한다.

 

 

이렇게 설정하고 재빌드 하고 insert를 하니 오류 해결완 !