jdbc integer value oid to big!

Lists: pgsql-jdbc
From: Danny Schueler <danny(dot)schueler(at)bvv(dot)bayern(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: jdbc integer value oid to big!
Date: 2007-03-05 15:44:26
Message-ID: 200703051644.26759.danny.schueler@bvv.bayern.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc


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(dot)schueler(at)bvv(dot)bayern(dot)de


From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Danny Schueler <danny(dot)schueler(at)bvv(dot)bayern(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: jdbc integer value oid to big!
Date: 2007-03-05 16:38:51
Message-ID: 45EC479B.3030208@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

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


From: Kris Jurka <books(at)ejurka(dot)com>
To: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
Cc: Danny Schueler <danny(dot)schueler(at)bvv(dot)bayern(dot)de>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: jdbc integer value oid to big!
Date: 2007-03-05 17:19:53
Message-ID: Pine.BSO.4.64.0703051217560.21492@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

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