No, wasNull is true if column value is null otherwise false.
You can have wasNull() is true but getInt() is zero. E.g. getInt() return
type is primitive and default value (zero) shoud be return for NULL fields.


On Thu, Nov 3, 2016 at 9:11 PM, Anil <anilk...@gmail.com> wrote:

> wasNull is false all the time for string types. correct ?
>
> On 3 November 2016 at 20:39, Andrey Mashenkov <amashen...@gridgain.com>
> wrote:
>
>> Javadoc says that null value should be returned.
>>
>> But from the other side, there is wasNull() method, that should be use
>> for null checks.
>>
>>
>>
>> On Thu, Nov 3, 2016 at 5:39 PM, Andrey Gura <ag...@apache.org> wrote:
>>
>>> String.valuOf(null) return "null" string by contract.
>>>
>>> On Thu, Nov 3, 2016 at 5:33 PM, Anil <anilk...@gmail.com> wrote:
>>>
>>>> HI ,
>>>>
>>>> null values are returned as "null" with ignite jdbc result set.
>>>>
>>>>  private <T> T getTypedValue(int colIdx, Class<T> cls) throws
>>>> SQLException {
>>>>         ensureNotClosed();
>>>>         ensureHasCurrentRow();
>>>>
>>>>         try {
>>>>             T val = cls == String.class ? (T)String.valueOf(curr.get(colIdx
>>>> - 1)) : (T)curr.get(colIdx - 1);
>>>>
>>>>             wasNull = val == null;
>>>>
>>>>             return val;
>>>>         }
>>>>         catch (IndexOutOfBoundsException ignored) {
>>>>             throw new SQLException("Invalid column index: " + colIdx);
>>>>         }
>>>>         catch (ClassCastException ignored) {
>>>>             throw new SQLException("Value is an not instance of " +
>>>> cls.getName());
>>>>         }
>>>>     }
>>>>
>>>>
>>>> if a column value is null (curr.get(colIdx - 1) return null but
>>>> String.valueOf( (curr.get(colIdx - 1) ) is not null it is "null".
>>>>
>>>> ArrayList<String> obj = new ArrayList<String>();
>>>>                           obj.add(null);
>>>> System.out.println(null == (String)String.valueOf(obj.get(0)));
>>>>
>>>> above Sysout is false.
>>>>
>>>> Fix :
>>>>
>>>> Object colValue = curr.get(colIdx - 1);
>>>>
>>>> T val = cls == String.class ? (String) colValue : (T) colValue;
>>>>
>>>> or return (T) colValue
>>>>
>>>>
>>>> please let me know if you see any issues. thanks
>>>>
>>>>
>>>>
>>>
>>
>

Reply via email to