From: | Bob Bruynooghe <rubbish(dot)bin1(at)mac(dot)com> |
---|---|
To: | Kris Jurka <books(at)ejurka(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: scale parameter to setObject method |
Date: | 2008-09-12 18:28:48 |
Message-ID: | 57DA0FFB-58BC-4799-ADA0-10B9A7EFE91E@mac.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On 11 Sep 2008, at 18:36, Kris Jurka wrote:
>
>
> On Fri, 5 Sep 2008, Bob Bruynooghe wrote:
>
>> I am calling the method setObject(int parameterIndex, Object x, int
>> targetSqlType) with NUMERIC as the targetSqlType and a BigDecimal
>> value of -92233720368.54775 as x. I expected the value placed in
>> the database to have no fractional part. In fact the database
>> contains -92233720368.54775.
>
> I'm not sure why you expect no fraction here, the numeric type does
> support fractional parts.
Well, it is because the Javadoc for the method says the following:
"This method is like the method setObject above, except that it
assumes a scale of zero."
The method that refers to is the version of setObject with 4
parameters and the Javadoc for that says
"scale - for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC
types, this is the number of digits after the decimal point."
The implementation of the 3 parameter setObject method in
AbstractJdbc2Statement is
public void setObject(int parameterIndex, Object x, int targetSqlType)
throws SQLException {
setObject(parameterIndex, x, targetSqlType, 0);
}
which matches the "assume a scale of zero".
This is the first time I have looked at this method and I was
surprised that the specified behaviour was to set the scale to zero
for NUMERIC parameters. I have no idea how other JDBC drivers
implement the method.
>
>
>> I have also tried using the method setObject(int parameterIndex,
>> Object x, int targetSqlType, int scale) and setting the scale
>> explicitly. The value of scale is being ignored.
>
> Yes, this is a bug in the driver.
>
> Kris Jurka
regards
Bob Bruynooghe
From | Date | Subject | |
---|---|---|---|
Next Message | JORGE LUIS MORALES MENDEZ | 2008-09-13 18:43:58 | Informacion del JDBC |
Previous Message | Andre Bialojahn | 2008-09-12 16:38:22 | Re: German translation fixes |