티스토리 뷰
          Error
          
        [Error] java.sql.SQLSyntaxErrorException: Incorrect integer value: '' for column
seungwonlee 2022. 8. 26. 18:10DBMS : MariaDB
오류 메시지 : java.sql.SQLSyntaxErrorException: Incorrect integer value: '' for column
mybatis에서 update문 실행했을 때 발생한 오류 메시지입니다.
update TEST_TABLE
set test_sn = #{testSn}test_sn의 datatype은 int type으로 #{testSn}의 값이 '' 공백으로 인해 발생한 오류입니다.
varchar type이었으면 나지 않을 에러인데 int type이라 발생한 오류인 거 같습니다.
해결방법으론 java 쪽에서 데이터 값이 '' 공백일 때 0으로 변경해서 넘겨주든지 여러 가지 방법이 있겠지만
저는 아래와 같이 case when then을 사용해서 해결했습니다.
update TEST_TABLE
set test_sn = case when #{testSn} = '' then null else #{testSn} end끝.
728x90
    
    
  'Error' 카테고리의 다른 글
| [Error] java.lang.NumberFormatException: For input string: "Y" (0) | 2022.09.27 | 
|---|
                      공지사항
                      
                  
                
                  
                  
                    최근에 올라온 글
                    
                
                  
                  
                    최근에 달린 댓글
                    
                
                  
                  - Total
- Today
- Yesterday
                    링크
                    
                
                  
                  
                    TAG
                    
                
                  
                  - Lower
- Upper
- zip
- operators
- Lambda
- bool
- Method
- isalpha
- permutations
- combinations
- If
- index
- for
- Built-in Functions
- function
- Python
- isdigit
- counter
- find
| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 
| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 
| 19 | 20 | 21 | 22 | 23 | 24 | 25 | 
| 26 | 27 | 28 | 29 | 30 | 31 | 
                    글 보관함
                    
                
            