[MyBatis] Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping
LeeDaniel2022. 11. 28. 17:46
-마이바티스에서 dao에서 받아온 파라미터를 바인딩 시켜 사용중인데 해당 에러 발생 마이바티스 파라미터 바인딩 코드 예제
[에러 로그] Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='searchSdate', mode=IN, javaType=class java.lang.String, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: 부적합한 열 인덱스 구글링 해보면 보통 jdbcType이 null이므로 null을 허용할수있게 mybatis config xml에 null허용 옵션을 추가하거나 바인딩 변수에 jdbcType을 직접 지정해주라는 방법들이 많이 나오는데 나의 경우에는 둘다 해봤지만 결과는 동일했다
✔ Solution 나의 경우에는 해당 바인딩 변수가 나타나기 이전 SQL문법이 틀렸었고 작은따옴표(')를 실수로 잘못 작성했었다 에러로그만 보고 SQL은 당연히 문제없다고 생각했기때문에 해결하는데 오래걸렸다 jdbcType에 대해 처리해줘도 동일하다면 SQL문법을 다시한번 꼼꼼히 살펴보자