Thread: jdbc integer value oid to big!

jdbc integer value oid to big!

From
Danny Schueler
Date:
I try to use WFS-Tools like deegree or geoserver.
Both are based on the jdbc-psql driver, to connect to a postgis-database.

org.postgresql.util.PSQLException: Bad value for type int int : 3364667332.
        at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2630)
        at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:1968)
        at org.postgresql.jdbc2.TypeInfoCache.getPGType(TypeInfoCache.java:161)
        at org.postgresql.jdbc2.AbstractJdbc2Connection.getPGType(AbstractJdbc2Connection.java:974)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setPGobject(AbstractJdbc2Statement.java:1539)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1678)
        at org.postgresql.jdbc3.AbstractJdbc3Statement.setObject(AbstractJdbc3Statement.java:1438)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1689)
        at org.deegree.io.datastore.sql.AbstractSQLDatastore.prepareStatement(Unknown Source)
        at org.deegree.io.datastore.sql.QueryHandler.performContentQuery(Unknown Source)
        at org.deegree.io.datastore.sql.QueryHandler.performQuery(Unknown Source)
        at org.deegree.io.datastore.sql.AbstractSQLDatastore.performQuery(Unknown Source)
        at org.deegree.io.datastore.sql.AbstractSQLDatastore.performQuery(Unknown Source)
        at org.deegree.io.datastore.schema.MappedFeatureType.performQuery(Unknown Source)
        at org.deegree.ogcwebservices.wfs.GetFeatureHandler$Performer.run(Unknown Source)

jdbc tries to connect to my huge database, where millions of geographic datasets are stored.
In the next step, the software tries to detect the java-type of the values. For this issue, it is necessary,
the determine the databases-oid of the dataset or the oid of the row.
both are above 2,1 billion (above 2^31) in my postgres-db!

It seems, that the jdbc-function "AbstractJdbc2ResultSet.toInt" can't handle those values and throws this error,
when it tries to parse the string to integer (the Type for this value was returned from the TypeInfoCache)

for Example
:
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://foo:/bar";
AbstractJdbc2Connection conn = (AbstractJdbc2Connection)DriverManager.getConnection(url, "postgres" , "");
TypeInfoCache tic = new TypeInfoCache(conn);
Statement st = conn.createStatement(AbstractJdbc2ResultSet.TYPE_FORWARD_ONLY,AbstractJdbc2ResultSet.CONCUR_READ_ONLY);
AbstractJdbc2ResultSet rs=(AbstractJdbc2ResultSet)st.executeQuery("select oid,obnr,poly from table limit 1;");
while (rs.next()) {
    if (tic.getJavaClass(rs.getColumnOID(1)).equals("java.lang.Integer")) {
        int value = rs.getInt(1);
    }
}

in short: The software detects the db-oids, determies the type of the values with the
TypeInfoCache and gets Integer. The following attemt, to get the variable in it's original type,
fails and results in an error!
The database can handle integer values with max. values until 2^32 as oid (unsigned),
the jdbc can handle only 2^31 (signed).

What can i do, to fix this Problem?







--
Mit freundlichen Grüßen
Danny Schüler

Sachgebiet 423 Bereitstellung von Fachdaten
Landesamt für Vermessung und Geoinformation
Alexandrastraße 4, 80538 München
Tel:  089 2129-2958
Fax:  089 2129-22958
Mail: danny.schueler@bvv.bayern.de

Re: jdbc integer value oid to big!

From
Heikki Linnakangas
Date:
Danny Schueler wrote:
> in short: The software detects the db-oids, determies the type of the values with the
> TypeInfoCache and gets Integer. The following attemt, to get the variable in it's original type,
> fails and results in an error!
> The database can handle integer values with max. values until 2^32 as oid (unsigned),
> the jdbc can handle only 2^31 (signed).
>
> What can i do, to fix this Problem?

That was fixed in CVS head few weeks ago. If you need the fix
immediately, you can checkout the latest CVS version and build the
driver yourself.

I think we should backpatch the fix...

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Re: jdbc integer value oid to big!

From
Kris Jurka
Date:

On Mon, 5 Mar 2007, Heikki Linnakangas wrote:

> I think we should backpatch the fix...
>

I was hesitant to backpatch this particular fix because I was concerned
about breaking existing code.  I don't think we can change the default
return type for oid from Integer to Long in a minor release.

Kris Jurka