From: Danny Schueler <danny.schueler@bvv.bayern.de>
To: pgsql-jdbc@postgresql.org
Subject: jdbc integer value oid to big!
Date: Mon, 5 Mar 2007 16:44:26 +0100
Message-ID: <200703051644.26759.danny.schueler@bvv.bayern.de> (raw)
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
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: danny.schueler@bvv.bayern.de
Subject: Re: jdbc integer value oid to big!
In-Reply-To: <200703051644.26759.danny.schueler@bvv.bayern.de>
References: <200703051644.26759.danny.schueler@bvv.bayern.de>
* 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