dbTalk Databases Forums  

[BUGS] BUG #1192: JDBC driver: org.postgresql.jdbc2.Array throws Bad BigDecimal Exception

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #1192: JDBC driver: org.postgresql.jdbc2.Array throws Bad BigDecimal Exception in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
PostgreSQL Bugs List
 
Posts: n/a

Default [BUGS] BUG #1192: JDBC driver: org.postgresql.jdbc2.Array throws Bad BigDecimal Exception - 07-14-2004 , 02:23 AM







The following bug has been logged online:

Bug reference: 1192
Logged by: oliver dauben (adc hofheim)

Email address: oliver (AT) arachnerd (DOT) de

PostgreSQL version: 7.4

Operating system: any (tested w/ win NT, win XP, linux 2.4.x)

Description: JDBC driver: org.postgresql.jdbc2.Array throws Bad
BigDecimal Exception

Details:

i'm working with NUMERIC(32,16) arrays in a DB table.

psql retrieval works without any problems.

nevertheless, JDBC retrieval causes a 'Bad BigDecimal Exception' beeing
thrown for cases when there are non- integer values in the corresponding
array.

in other words there is no problem getting a "3.0, 4.0, 5.0" array back into
java but "3.1, 4.1, 5.1" will throw a BBDE.

this behaviour is exposed - at least - by the postgresql 7.3 and the latest
production grade 7.4 JDBC drivers.

i traced things down to the 'org.postgresql.jdbc2.Array' class where i found
a line reading

AbstractJdbc2ResultSet.toBigDecimal( arrayContents[(int)index++], 0 );

in the switch/case of the base tyope for Type.NUMERIC. initializing a java
BigDecimal with a scale of '0' (the second argument in the method call)
causes an exception because for example "3.1" cannot be exactly represented
by a BigDecimal with scale '0'.

FIX PROPOSAL:

changing the scale to '-1' ('autoscale') will allow for proper casts agains
BigDecimal and works fine for me:

AbstractJdbc2ResultSet.toBigDecimal( arrayContents[(int)index++], -1 );

hope this helps, cheers, oLiVeR.


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

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.