Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Jdbc > Bug while retri...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 1894 of 1984
Post > Topic >>

Bug while retrieving money data type from db

by aaime@[EMAIL PROTECTED] (Andrea Aime) Feb 26, 2008 at 02:36 PM

This is a multi-part message in MIME format.
--------------040307010004010306000107
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi,
I've stumbled into a bug, it seems the driver is not able to
retrive money data type from the db properly unless a getString
is used.... unfortunately in my case the code does not know
what kind of attributes is reading, and it uses getObject instead,
getting back an exception.

Running the attached code all I get is:

Exception in thread "main" org.postgresql.util.PSQLException: Il valore 
«1,000.00» non č adeguato al tipo «double».
	at 
org.postgresql.jdbc2.AbstractJdbc2ResultSet.toDouble(AbstractJdbc2ResultSet.java:2645)
	at 
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getDouble(AbstractJdbc2ResultSet.java:2032)
	at 
org.postgresql.jdbc2.AbstractJdbc2ResultSet.internalGetObject(AbstractJdbc2ResultSet.java:134)
	at 
org.postgresql.jdbc3.AbstractJdbc3ResultSet.internalGetObject(AbstractJdbc3ResultSet.java:39)
	at 
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getObject(AbstractJdbc2ResultSet.java:2348)
	at PgMoneyIssue.main(PgMoneyIssue.java:15)

(translated from italian, "the value 1,000.00 is not adequate for the 
type double". Not sure if the problem is locale dependent, since it has 
been re****ted as a GeoServer bug by a user living in USA, and I then 
tracked it down to this issue with the driver).

I looked for a bug tracker but could not find one, so here I am, posting
the bug re****t to the ml.

Contact me back if you need any further information
Cheers
Andrea


--------------040307010004010306000107
Content-Type: text/plain;
 name="PgMoneyIssue.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="PgMoneyIssue.java"

im****t java.sql.Connection;
im****t java.sql.DriverManager;
im****t java.sql.ResultSet;
im****t java.sql.Statement;

/*
 
 To run this example run the following sql:

CREATE TABLE testmoney (
    id serial,
    cost money NOT NULL
);
INSERT INTO testmoney (id, cost) VALUES (1, '$999.00');
INSERT INTO testmoney (id, cost) VALUES (2, '$1,000.00');
INSERT INTO testmoney (id, cost) VALUES (3, '$10,000.01');

and then fix the connection paramters
 
 */

public class PgMoneyIssue {
    public static void main(String[] args) throws Exception {
        Class.forName("org.postgresql.Driver");
        Connection conn =
DriverManager.getConnection("jdbc:postgresql://localhost/postgis",
"username", "password");
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("select * from testmoney");
        while(rs.next()) {
            System.out.println(rs.getObject(1));
            System.out.println(rs.getObject(2));  // kaboom on the second
record!
        }
    }
}

--------------040307010004010306000107
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


---------------------------(end of broadcast)---------------------------
TIP 7: You can help sup****t the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

--------------040307010004010306000107--
 




 4 Posts in Topic:
Bug while retrieving money data type from db
aaime@[EMAIL PROTECTED]   2008-02-26 14:36:07 
Re: Bug while retrieving money data type from db
books@[EMAIL PROTECTED]   2008-02-29 12:09:52 
Re: Bug while retrieving money data type from db
dmigowski@[EMAIL PROTECTE  2008-02-29 18:36:53 
Re: Bug while retrieving money data type from db
books@[EMAIL PROTECTED]   2008-02-29 12:57:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Sun Jul 6 19:03:16 CDT 2008.