db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xavier Maysonnave <xav...@omondo.com>
Subject Re: Antwort: Village
Date Mon, 22 Mar 2004 11:40:44 GMT


Xavier Maysonnave wrote:

> Hi,
> 
> Thank you for your response.
> 
> I am not referencing my code but the village code :
> 
> http://share.whichever.com/viewcvs.cgi/village/com/workingdogs/village/Value.java?rev=1.20&content-type=text/vnd.viewcvs-markup

> 
> 
> Take a look in the constructor, you should see this code snippet :
> 
>             case Types.DECIMAL:
>                 String number = rs.getString (columnNumber);
>                 if ( number == null )
>                 {
>                     valueObject = null;
>                 }
>                 else
>                 {
>                     valueObject = new BigDecimal (number);
>                 }
>                 break;

The patch could be the following :

	            case Types.DECIMAL:
	            	valueObject = rs.getBigDecimal(columnNumber);
	                break;

Thanks for your suggestions.

> 
> This is where the code crash.
> 
> Maybe your proposition :
> 
> BigDecimal bd = record.getValue(1).asBigDecimal();
> 
> is the right one.
> 
> Thanks
> 
> FlorianFray@deuka.de wrote:
> 
>> There is no error in Village but in your code.
>> The  DB does return correct values. You tried to convert a decimal 
>> value to a String and then back to a BigDecimal.
>>
>> Solution 1: Try to get a BigDecimal from the Village record.
>> Code example:
>> Record record; ...
>> BigDecimal bd = record.getValue(1).asBigDecimal();
>>
>> Solution 2:
>> Try to use a java.text.NumberFormatter to retrieve the BigDecimal value.
>> Here's a code example:
>> String numberStr = "0,50";
>> NumberFormatter nf = NumberFormatter.getInstance(Locale.FRANCE);
>> Number number = nf.parse(strVal);
>> BigDecimal bd;
>> if (number instanceof BigDecimal) {
>>   bd = (BigDecimal) number;
>> } else {
>>   bd = new BigDecimal(number.doubleValue());
>> }
>>
>>
>> deuka Deutsche Tiernahrung GmbH & Co. KG
>> Tel.: 0211 / 3034 - Fax: 0211 / 3034 - 376
>> eMail: FlorianFray@deuka.de
>> WebSite: www.deuka.de
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message