오류내용

mybatis에서 문자열 비교를 할때 같음을 아래와 같이 작성했을때 다다음과 같은 오류가 발생하였다.

<choose>

   <when test="salesType == 'B'">

     AND b.country = 'KR'

   </when>

   <when test="salesType == 'C'">

AND b.country &lt;&gt; 'KR'

   </when>

   <otherwise> AND 1=1 </otherwise>

/choose>

### Error querying database.  Cause: java.lang.NumberFormatException: For input string: "A"

### Cause: java.lang.NumberFormatException: For input string: "A"] with root cause

java.lang.NumberFormatException: For input string: "A"


해결

<choose>

<when test="salesType.equalsIgnoreCase('B')">

      AND b.country = 'KR'

</when>

<when test="salesType.equalsIgnoreCase('C')">

 AND b.country &lt;&gt; 'KR'

</when>

<otherwise> AND 1=1 </otherwise>

</choose>

ms-sql이라 equalsIgnoreCase를 사용했고 oracle이었으면 equals를 썼을듯.


<insert id="insert" parametertype="VO" usegeneratedkeys="true" keyproperty="col0"> 
    INSERT INTO table_name 
    <trim prefix="(" suffix=")" suffixoverrides=",">
	<if test="col1 != ''"> col1, </if>
    </trim>
    <trim prefix="VALUES (" suffix=")" suffixoverrides=",">
        <if test="col1 != ''"> #, </if>
    </trim>
</insert>

 

'Java' 카테고리의 다른 글

사이트 긁어오기  (0) 2015.08.19
mail 발송  (0) 2015.08.18
MS-SQL JDBC 추가하기.  (0) 2014.07.28
MIME 타입 알아내는 방법  (0) 2013.10.02
JSTL에서 substring, length  (0) 2013.09.26

+ Recent posts