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

[EMAIL PROTECTED] 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: [EMAIL PROTECTED] WebSite: www.deuka.de


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to