Hi,
I just found an incorrect handling of java Long values in the
getObject(int col) method of the RS class.
This method always returns an Integer object if the sqlite column type
is integer, but sqlite can store 6 and 8 byte values in this column,
too. (http://www.sqlite.org/datatype3.html)
Which leads to an overflow and an incorrect value.

Instead of:

    public Object getObject(int col) throws SQLException {
        switch (db.column_type(pointer, checkCol(col))) {
            case SQLITE_INTEGER: return new Integer(getInt(col));
            case SQLITE_FLOAT:   return new Double(getDouble(col));
            case SQLITE_BLOB:    return getBytes(col);
            case SQLITE_NULL:    return null;
            case SQLITE_TEXT:
            default:
                return getString(col);
        }
    }

maybe there should be something like this:

    public Object getObject(int col) throws SQLException {
        switch (db.column_type(pointer, checkCol(col))) {
            case SQLITE_INTEGER: {
             long value = getLong(col);
             if(value > Integer.MAX_VALUE ||
               value < Integer.MIN_VALUE){
              return new Long(value);
             }
             return new Integer((int)value);
            }
            case SQLITE_FLOAT:   return new Double(getDouble(col));
            case SQLITE_BLOB:    return getBytes(col);
            case SQLITE_NULL:    return null;
            case SQLITE_TEXT:
            default:
                return getString(col);
        }
    }

Kind regards,

Georg
--~--~---------~--~----~------------~-------~--~----~
Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en
To unsubscribe, send email to [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to