From: otran <otran@switchfly.com>
To: pgsql-jdbc@postgresql.org
Subject: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
Date: Fri, 9 Mar 2012 13:25:20 -0800 (PST)
Message-ID: <1331328320772-5551763.post@n5.nabble.com> (raw)
Hi,
We are in the process of upgrading from Postgres JDBC 8.4 to 9.1-901-1.jdbc4
and discovered that CacheRowSet now call the methods isAutoIncrement() and
fetchFieldMetaData(), which will fail converting a OID to an int.
The following code works with the 8.4 driver, but fails with 9.1:
public static void main(String[] args) throws Exception {
Properties connectionProperties = new Properties();
connectionProperties.put("user", "otran");
connectionProperties.put("pass", "”);
Class.forName("org.postgresql.Driver");
Connection connection =
DriverManager.getConnection("jdbc:postgresql://postgres-9.1",
connectionProperties);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select * from
airports");
CachedRowSet cachedRowSet = new CachedRowSetImpl();
cachedRowSet.populate(resultSet);
}
$ export CLASSPATH=postgresql-8.4-702.jdbc4.jar:.
$ java Test
$ export CLASSPATH=postgresql-9.1-901-1.jdbc4.jar:.
$ java Test
Exception in thread "main" org.postgresql.util.PSQLException: Bad value for
type int : 3090704121
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2731)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:1983)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.fetchFieldMetaData(AbstractJdbc2ResultSetMetaData.java:242)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.isAutoIncrement(AbstractJdbc2ResultSetMetaData.java:61)
at
com.sun.rowset.CachedRowSetImpl.initMetaData(CachedRowSetImpl.java:701)
at
com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:621)
at Test.main(Test.java:22)
It only affects our production environments where the oids are larger than
an int, but many of our tables have that issue. We can try ripping out
CachedRowSets, but wonder if someone has a fix.
Seems related to:
RELEASE NOTE...
With Version 89.3-dev600 (2007-04-18). Make the default object return type
of oids to be a Java Long instead of Integer because oids are unsigned and
exceed the range of Integer. (jurka)
http://postgresql.1045698.n5.nabble.com/oid-as-long-type-td2169988.html
Thanks,
Owen
--
View this message in context: http://postgresql.1045698.n5.nabble.com/oid-int-issue-with-CachedRowSet-upgrading-from-JDBC-8-4-to-9...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: otran@switchfly.com
Subject: Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
In-Reply-To: <1331328320772-5551763.post@n5.nabble.com>
References: <1331328320772-5551763.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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