dbTalk Databases Forums  

Re: org.postgresql.util.PSQLException: Bad value for type int

comp.databases.postgresql comp.databases.postgresql


Discuss Re: org.postgresql.util.PSQLException: Bad value for type int in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
HansH
 
Posts: n/a

Default Re: org.postgresql.util.PSQLException: Bad value for type int - 12-09-2006 , 05:47 PM






"Michael Ruf" <usenet.rufmichael (AT) gmx (DOT) de> schreef in bericht
news:45794391$0$18843$9b4e6d93 (AT) newsspool4 (DOT) arcor-online.net...
Quote:
ich bekomme momentan auf einer Postgres DB ( 8.1.3 ) beim Zugriff mittels
JDBC ( 8.1 800dev ) auf BLOBs den folgenden Fehler
org.postgresql.util.PSQLException: Bad value for type int : 2338491788.

Den Fehler bekomme ich nur für neu angelegte BLOBs ( seit ca. einer
Woche ), alte funktionieren noch. Das schreiben der BLOBs funktioniert,
erst das Auslesen macht Probleme. So wie es für mich aussieht sind die
OIDs "übergelaufen".
I'ld rather say JDBC treates the unsigned 4 byte value as signed by mistake.
When writing the new OID is system generated beyond JDBC's control.

http://www.postgresql.org/docs/faqs.FAQ.html#item4.12
What is an OID?
If a table is created WITH OIDS, each row gets a unique OID. OIDs are
automatically assigned unique 4-byte integers that are unique across the
entire installation. However, they overflow at *4 billion*, and then the
OIDs start being duplicated. PostgreSQL uses OIDs to link its internal
system tables together.

Quote:
... Kann man Postgres irgendwie dazu bringen "kleinere" OIDs zu erzeugen.
Dumping, recreating and reloading your datebase will only assign an OID to
currently present objects. It is likely you 'll end with a last used OID
below the current 2,338,491,788 increasing. Consuming about 200,000,000 OIDs
in about a week worries me, it would only take half a year eat all 4 billion
OIDs ...

While you are at it consider to (re)create your tables without OIDs -default
as of version 8.1- , that limits the use of OIDs is to system tables.
Unfortunately blobs are stored in a system table -pg_catelog.pg_largeobject-
and will keep using OIDs, you may also have to convert your blob into bytea.

HansH






Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: org.postgresql.util.PSQLException: Bad value for type int - 12-11-2006 , 03:04 AM






Michael Ruf <usenet.rufmichael (AT) gmx (DOT) de> wrote:
Quote:
ich bekomme momentan auf einer Postgres DB ( 8.1.3 ) beim Zugriff
mittels JDBC ( 8.1 800dev ) auf BLOBs den folgenden Fehler
org.postgresql.util.PSQLException: Bad value for type int : 2338491788.

Den Fehler bekomme ich nur für neu angelegte BLOBs ( seit ca. einer
Woche ), alte funktionieren noch. Das schreiben der BLOBs funktioniert,
erst das Auslesen macht Probleme. So wie es für mich aussieht sind die
OIDs "übergelaufen".
This is an English speaking newsgroup!

Translating:
He is getting an
org.postgresql.util.PSQLException: Bad value for type int : 2338491788
when he tries to access a large object with OID 2338491788 as a BLOB
from JDBC.

I think that you have found a bug in the JDBC driver.
The driver treats OIDs as 'int' (which is a 4 byte signed integer), while
OIDs are really 4 byte _unsigned_ integers. 'long' would be more
appropriate.

I'll inform the pgsql-JDBC mailing list!

Yours,
Laurenz Albe



Reply With Quote
  #3  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: org.postgresql.util.PSQLException: Bad value for type int - 12-12-2006 , 02:11 AM



Laurenz Albe <invite (AT) spam (DOT) to.invalid> wrote:
Quote:
He is getting an
org.postgresql.util.PSQLException: Bad value for type int : 2338491788
when he tries to access a large object with OID 2338491788 as a BLOB
from JDBC.

I think that you have found a bug in the JDBC driver.
The driver treats OIDs as 'int' (which is a 4 byte signed integer), while
OIDs are really 4 byte _unsigned_ integers. 'long' would be more
appropriate.

I'll inform the pgsql-JDBC mailing list!
The problem is already known, see
http://archives.postgresql.org/pgsql...eads.php#00052

Unfortunately it seems that nobody is too keen on fixing it:

"So this is a known problem, but one we've generally avoided dealing
with because few people actually bump into it."

You could either implement a fix yourself or pester the developers :^)

Unfortunately I think that there is no way to work araund the problem.

Yours,
Laurenz Albe


Reply With Quote
  #4  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: org.postgresql.util.PSQLException: Bad value for type int - 12-13-2006 , 11:00 AM



Michael Ruf <usenet.rufmichael (AT) gmx (DOT) de> wrote:
Quote:
We've found a workaround that fits our needs.
Thanks for sharing this, it is most useful!

Yours,
Laurenz Albe


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.