sqlite-jdbc icon indicating copy to clipboard operation
sqlite-jdbc copied to clipboard

JDBC reports wrong type INTEGER but value is LONG

Open sproket opened this issue 3 years ago • 0 comments

using 3.34.0 sqlite-jdbc

Create the following table

    sql = "CREATE TABLE DateTestSQLTypes ( " +
            " ID INT, " +
            " Description VARCHAR(100), " +
            " DateOnly DATE, " +
            " TimeOnly TIME," +
            " UtilDateAndTime DATETIME, " +
            " DateAndTime DATETIME) ";

With JDBC insert a row. Then read back the row.

using ResultsetMetaData look at the types (for TimeOnly) column.

JDBC java.sql.Types reports 4 = INTEGER

value read back with getObject is actually a LONG.

If you read back with getInt() you get an integer wrapped back as a negative number (wrong value).

If the value is LONG the java.sql.Types should be -5 BIGINT

sproket avatar May 12 '21 10:05 sproket