Bad value for int when using Postgres

Hi

We ran into to “Bad value for int” in version 2.0.1. Postgres has oid that references tables. An oid is a four byte unsigned integer. Using ResultSet.getInt thus may give the error in this message’s subject.

Here is a code snippet from PostgresDatabaseSnapshotGenerator.java:

  1.     @Override
        protected void readUniqueConstraints(DatabaseSnapshot snapshot, String schema, DatabaseMetaData databaseMetaData) throws DatabaseException, SQLException {
            Database database = snapshot.getDatabase();
            updateListeners(“Reading unique constraints for " + database.toString() + " …”);
            List foundUC = new ArrayList();
            PreparedStatement statement = null;
            ResultSet rs = null;
            try {
                statement = ((JdbcConnection) database.getConnection()).getUnderlyingConnection().prepareStatement(“select pgc.conname, pgc.conrelid, pgc.conkey, pgcl.relname from pg_constraint pgc inner join pg_class pgcl on pgcl.oid = pgc.conrelid and pgcl.relkind =‘r’ where contype = ‘u’”);
                rs = statement.executeQuery();
                while (rs.next()) {
                    String constraintName = rs.getString(“conname”);
                    int conrelid = rs.getInt(“conrelid”);
The last line is where the trouble is. The JDBC driver (v 9.0-801) gets the oid as a string which it tries to parse as an int. Since it is unsigned, it may very well be out of range for an int.

Regards
  Per

This has been resolved in trunk for the upcoming 2.0.2 release


Nathan

Ty!

Per