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

Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: otran <otran(at)switchfly(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
Date: 2012-03-09 22:06:25
Message-ID: CADK3HHLNi0r9ex5Omn4NbaX=w9=yfDMUv0YqTJjhrpcnG6GL0w@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
On Fri, Mar 9, 2012 at 4:25 PM, otran <otran(at)switchfly(dot)com> wrote:
> 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.
>

If your oid's exceed an int, then I don't see how CachedRowSets could
possibly work ?


Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

In response to

Responses

pgsql-jdbc by date

Next:From: otranDate: 2012-03-09 22:59:45
Subject: Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
Previous:From: otranDate: 2012-03-09 21:25:20
Subject: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1

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