Обсуждение: Bug extracting money value
Hello! I always get an exception when I try to extract the money value I inserted this way: insert into public."dbtypes" ("cmoney") values ('7'). Java: Object oValue = m_resultSet.getObject(i); Stacktrace (postgresql-8.2dev-503.jdbc3.jar): org.postgresql.util.PSQLException: Bad value for type double : ?7,00 at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toDouble(AbstractJdbc2ResultSet.java:2594) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getDouble(AbstractJdbc2ResultSet.java:1975) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.internalGetObject(AbstractJdbc2ResultSet.java:132) at org.postgresql.jdbc3.AbstractJdbc3ResultSet.internalGetObject(AbstractJdbc3ResultSet.java:39) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getObject(AbstractJdbc2ResultSet.java:2291) resultSet.getDouble(i); doesn't work either. resultSet.getString(i); returns '?7,00' without exception. Tested with: PostgreSQL 8.1.4 on Windows 2000 JDBC driver: postgresql-8.2dev-503.jdbc3.jar AND postgresql-8.1-407.jdbc3.jar Thanks Holger
Holger Schulz wrote: > I always get an exception when I try to extract the money value I inserted this way: "money" isn't a well-supported type on the server side (I believe its use is no longer recommended) .. IIRC the formatting rules for it are locale-specific, among other problems. > Object oValue = m_resultSet.getObject(i); > org.postgresql.util.PSQLException: Bad value for type double : ?7,00 ... though I'd expect at least getObject to work, if not getDouble() Maybe you could dig into this and send us a patch? -O
Hi, Oliver, Oliver Jowett wrote: >> I always get an exception when I try to extract the money value I >> inserted this way: > > "money" isn't a well-supported type on the server side (I believe its > use is no longer recommended) .. IIRC the formatting rules for it are > locale-specific, among other problems. Without having looked at the code, I think that the ? in getString() comes from the backend formatting the Value with an EUR symbol, and the JDBC driver looking for a $ to skip. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in Europe! www.ffii.org www.nosoftwarepatents.org
Hi, All, Markus Schaber wrote: > Without having looked at the code, I think that the ? in getString() > comes from the backend formatting the Value with an EUR symbol, and the > JDBC driver looking for a $ to skip. I now looked at the code. It seems that the Code tries to strip brackets () and anything outside of them, however, I did not get my backend to generate anything containing brackets. With the US locale, it generated '$5.00' and '-$5.00', with the european locale, it generated '5.00' and '-5.00'. HTH Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in Europe! www.ffii.org www.nosoftwarepatents.org
On 1-Oct-06, at 5:11 PM, Oliver Jowett wrote: > Holger Schulz wrote: > >> I always get an exception when I try to extract the money value I >> inserted this way: > > "money" isn't a well-supported type on the server side (I believe > its use is no longer recommended) This is still being debated, and will likely be reversed as there is a proposal on the table for a new improved money type > .. IIRC the formatting rules for it are locale-specific, among > other problems. > >> Object oValue = m_resultSet.getObject(i); > >> org.postgresql.util.PSQLException: Bad value for type double : ?7,00 > > ... though I'd expect at least getObject to work, if not getDouble() > > Maybe you could dig into this and send us a patch? > > -O > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq >