ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hu-yl@neusoft.com" <hu...@neusoft.com>
Subject argument type mismatch of oracle TIMESTAMP field when call loadCache
Date Mon, 27 Jun 2016 22:46:11 GMT

    When I loaded the data from oracle through cache.loadData.
    The exception which is  argument type mismatch of oracle TIMESTAMP happened.

    The detail: 
    I produced the schema through the tool schema-import-tool.
    A pojo object is Kc21, and it has a property Bkc192, its type is java.sql.Timestamp
    The setter is the following:
    public void x.x.x.x.Kc21.setBkc192(java.sql.Timestamp)

    When I debuging the code, I found:
    In the following method, there is a problem.

    protected Object getColumnValue(ResultSet rs, int colIdx, Class<?> type) throws
SQLException {
    //the parameter type is class java.sql.Timestamp
    Object val = rs.getObject(colIdx);
    And the val reading from oracle ResultSet is TIMESTAMP

    So the val's type TIMESTAMP is different from java.sql.Timestamp and get the exception
"argument type mismatch".    

    The whole method is the following, there is not handling about the type java.sql.Timestamp
    protected Object getColumnValue(ResultSet rs, int colIdx, Class<?> type) throws
SQLException {
        Object val = rs.getObject(colIdx);

        if (val == null)
            return null;

        if (type == int.class)
            return rs.getInt(colIdx);

        if (type == long.class)
            return rs.getLong(colIdx);

        if (type == double.class)
            return rs.getDouble(colIdx);

        if (type == boolean.class || type == Boolean.class)
            return rs.getBoolean(colIdx);

        if (type == byte.class)
            return rs.getByte(colIdx);

        if (type == short.class)
            return rs.getShort(colIdx);

        if (type == float.class)
            return rs.getFloat(colIdx);

        if (type == Integer.class || type == Long.class || type == Double.class ||
            type == Byte.class || type == Short.class ||  type == Float.class) {
            Number num = (Number)val;

            if (type == Integer.class)
                return num.intValue();
            else if (type == Long.class)
                return num.longValue();
            else if (type == Double.class)
                return num.doubleValue();
            else if (type == Byte.class)
                return num.byteValue();
            else if (type == Short.class)
                return num.shortValue();
            else if (type == Float.class)
                return num.floatValue();

        if (type == UUID.class) {
            if (val instanceof UUID)
                return val;

            if (val instanceof byte[]) {
                ByteBuffer bb = ByteBuffer.wrap((byte[])val);

                long most = bb.getLong();
                long least = bb.getLong();

                return new UUID(most, least);

            if (val instanceof String)
                return UUID.fromString((String)val);

        // Workaround for known issue with Oracle JDBC driver https://community.oracle.com/thread/2355464?tstart=0
        if (type == java.sql.Date.class && val instanceof java.util.Date)
            return new java.sql.Date(((java.util.Date)val).getTime());

        return val;

    Thank you for any reply.

View raw message