pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedInteger is not a subclass of Short
5+ messages / 3 participants
[nested] [flat]
* Integer is not a subclass of Short
@ 2010-07-29 23:28 Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
2010-07-29 23:49 ` Re: Integer is not a subclass of Short Kris Jurka <books@ejurka.com>
2010-07-29 23:51 ` Re: Integer is not a subclass of Short Oliver Jowett <oliver@opencloud.com>
0 siblings, 2 replies; 5+ messages in thread
From: Lloyd Parkes @ 2010-07-29 23:28 UTC (permalink / raw)
To: pgsql-jdbc
Hi all,
I have found a problem with a discrepancy between getColumnClassName()
in jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
and internalGetObject() in
jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java.
The former is defined (indirectly) to return the fully qualified class
name of (a possible superclass of) the object returned by the latter.
For a smallint column, the former returns "java.lang.Short", but the
latter returns a java.lang.Integer. Short is neither Integer, nor a
superclass of Integer.
I guess someone should add the line "return new
Short(getShort(columnIndex));" between lines 123 and 124 of rev 1.108 of
AbstractJdbc2ResultSet.java. There may be a similar problem with tinyint
columns, but I don't have any tinyint columns.
Cheers,
Lloyd
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Integer is not a subclass of Short
2010-07-29 23:28 Integer is not a subclass of Short Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
@ 2010-07-29 23:49 ` Kris Jurka <books@ejurka.com>
2010-07-29 23:50 ` Re: Integer is not a subclass of Short Kris Jurka <books@ejurka.com>
1 sibling, 1 reply; 5+ messages in thread
From: Kris Jurka @ 2010-07-29 23:49 UTC (permalink / raw)
To: Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>; +Cc: pgsql-jdbc
On Fri, 30 Jul 2010, Lloyd Parkes wrote:
> I have found a problem with a discrepancy between getColumnClassName()
> in jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
> and internalGetObject() in
> jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java.
>
> The former is defined (indirectly) to return the fully qualified class
> name of (a possible superclass of) the object returned by the latter.
> For a smallint column, the former returns "java.lang.Short", but the
> latter returns a java.lang.Integer. Short is neither Integer, nor a
> superclass of Integer.
According to my attached testcase getColumnClassName does return Integer.
> I guess someone should add the line "return new
> Short(getShort(columnIndex));" between lines 123 and 124 of rev 1.108 of
> AbstractJdbc2ResultSet.java. There may be a similar problem with tinyint
> columns, but I don't have any tinyint columns.
The spec requires the return type for smallint to be Integer. See table
B-3 of the JDBC4 spec.
Kris Jurka
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Integer is not a subclass of Short
2010-07-29 23:28 Integer is not a subclass of Short Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
2010-07-29 23:49 ` Re: Integer is not a subclass of Short Kris Jurka <books@ejurka.com>
@ 2010-07-29 23:50 ` Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 5+ messages in thread
From: Kris Jurka @ 2010-07-29 23:50 UTC (permalink / raw)
To: Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>; +Cc: pgsql-jdbc
On Thu, 29 Jul 2010, Kris Jurka wrote:
> According to my attached testcase getColumnClassName does return Integer.
>
Actually attached now...
Kris Jurka
Attachments:
TestShort.java (text/plain, 523B) download
import java.sql.*;
public class TestShort {
public static void main(String args[]) throws Exception {
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5910/jurka", "jurka", "");
Statement stmt = conn.createStatement();
stmt.execute("CREATE TEMP TABLE shorttest(a smallint)");
ResultSet rs = stmt.executeQuery("SELECT * FROM shorttest");
ResultSetMetaData rsmd = rs.getMetaData();
System.out.println(rsmd.getColumnClassName(1));
stmt.close();
conn.close();
}
}
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Integer is not a subclass of Short
2010-07-29 23:28 Integer is not a subclass of Short Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
@ 2010-07-29 23:51 ` Oliver Jowett <oliver@opencloud.com>
2010-07-31 22:20 ` Re: Integer is not a subclass of Short Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
1 sibling, 1 reply; 5+ messages in thread
From: Oliver Jowett @ 2010-07-29 23:51 UTC (permalink / raw)
To: Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>; +Cc: pgsql-jdbc
Lloyd Parkes wrote:
> Hi all,
> I have found a problem with a discrepancy between getColumnClassName()
> in jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
> and internalGetObject() in
> jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java.
>
> The former is defined (indirectly) to return the fully qualified class
> name of (a possible superclass of) the object returned by the latter.
> For a smallint column, the former returns "java.lang.Short", but the
> latter returns a java.lang.Integer. Short is neither Integer, nor a
> superclass of Integer.
>
> I guess someone should add the line "return new
> Short(getShort(columnIndex));" between lines 123 and 124 of rev 1.108 of
> AbstractJdbc2ResultSet.java. There may be a similar problem with tinyint
> columns, but I don't have any tinyint columns.
getObject() on a smallint column is correct to return an Integer (see
table B-3 in the JDBC spec), so if the metadata method is claiming it
should be a Short, then it's the metadata method that's wrong.
That said, I think you must be using a very old driver. The last time I
can see TypeInfoCache mapping int2 to "java.lang.Short" is back in the
8.1 driver branch. 8.2 and later should return "java.lang.Integer".
-O
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Integer is not a subclass of Short
2010-07-29 23:28 Integer is not a subclass of Short Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
2010-07-29 23:51 ` Re: Integer is not a subclass of Short Oliver Jowett <oliver@opencloud.com>
@ 2010-07-31 22:20 ` Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
0 siblings, 0 replies; 5+ messages in thread
From: Lloyd Parkes @ 2010-07-31 22:20 UTC (permalink / raw)
To: pgsql-jdbc
Thanks Kris and Oliver. I have only referred to the Javadoc API and
not the JDBC spec because the API is online and Sun felt that the JDBC
spec is best published through their online shopping system behind
half a dozen "click here" pages.
So, let's start with the information I should have provided a while
back. I'm using Java 1.5.0 on a Mac with postgresql-8.4-701.jdbc3.jar.
I'm also using PostgreSQL server 8.3.
> That said, I think you must be using a very old driver. The last
> time I
> can see TypeInfoCache mapping int2 to "java.lang.Short" is back in the
> 8.1 driver branch. 8.2 and later should return "java.lang.Integer".
Hmm. That's interesting. I have some secret sauce in my program. I'm
using the Spring Framework to drive a whole bunch of stuff in my
program and one of the things I get it to do is to make the JDBC cruft
around the small amount of SQL I use go away. And then it turns out
that I am using two lots of secret sauce. The Spring Framework returns
a RowSet rather than a ResultSet. The RowSet is supposed to be an
extension of the ResultSet interface, but it is the RowSet that
doesn't work.
When I ran Kris' test case, it printed out "java.lang.Integer". When I
modified the program to use a com.sun.rowset.CachedRowSetImpl, it
printed out "java.lang.Short". I guess this is a bug in Oracle's JDBC
code.
Thanks for your help,
Lloyd
Attachments:
TestShort.java (application/octet-stream, 493B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2010-07-31 22:20 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-07-29 23:28 Integer is not a subclass of Short Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
2010-07-29 23:49 ` Kris Jurka <books@ejurka.com>
2010-07-29 23:50 ` Kris Jurka <books@ejurka.com>
2010-07-29 23:51 ` Oliver Jowett <oliver@opencloud.com>
2010-07-31 22:20 ` Lloyd Parkes <Lloyd.Parkes@ecs.vuw.ac.nz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox