Skip site navigation (1) Skip section navigation (2)

Mismatched JDBC and Java Type

From: Mike Finn <mike(dot)finn-pgsql-jdbc(at)tacticalExecutive(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Mismatched JDBC and Java Type
Date: 2001-04-27 17:45:48
Message-ID: 01042711454803.01052@birch.tacticalExecutive.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
I am using a short (Short) in my application for a particular data field
My understanding is that this should map to the JDBC type 'smallInt' which
in turn maps to the postgresql type int2.

However when I retrieve data via JDBC (jdbc7.0-1.2.jar, 7.0.3-2 engine)
the int2 fields are returned as java.lang.Integer instead of java.lang.Short.

Is this a bug?

----------- Example code below ----------
    ResultSetMetaData md = rs.getMetaData();
    while (rs.next()) {
        for (int c=1; c <= md.getColumnCount(); c++) {
            Object obj = rs.getObject(c);
            Logger.println(c +
                           "\tcolumnName=" + md.getColumnName(c) +
                           "\tcolumnType=" + md.getColumnType(c) +
                           "\tcolumnTypeName=" + md.getColumnTypeName(c) +
                           "\tvalue=" + obj +
                           "\tvalueClass=" + obj.getClass().getName() );
 

will produce 

...
10 columnName=active  columnType=5  columnTypeName=int2  value=8  
valueClass=java.lang.Integer
...

note that md.getColumnClassName() is not implemented so I don't know what it 
would return.

===================
Mike Finn
Tactical Executive Systems
mike(dot)finn(at)tacticalExecutive(dot)com

Responses

pgsql-jdbc by date

Next:From: dejudiDate: 2001-04-28 08:23:04
Subject: JDBC installation
Previous:From: Peter T MountDate: 2001-04-27 13:45:06
Subject: Re: JDBC and Accents

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group