You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Xavier Maysonnave <xa...@omondo.com> on 2004/03/22 11:30:09 UTC
Village
Hi All,
is there someone who maintain the village distribution ?
While working on data export I've got some problems and fixed two issues.
For example :
1 -
In Value.java while exporting a database with a decimal column I got a value like '0,50'.
As you can notice the database send me a localized decimal value (I am working on a french
windows) with a ',' rather a value like '0.50'.
As a consequence the instruction :
valueObject = new BigDecimal (number);
crashed.
I just modified the code with the following :
number = number.replace(',', '.'); //EclipseDatabase added
valueObject = new BigDecimal (number);
2 -
Concerning blob retrieval, here is the following :
case Types.BLOB:
Blob blob = rs.getBlob(columnNumber);
valueObject = blob.getBytes(1, (int) blob.length());
break;
If the retrieved blob is null, it causes an exception. This could be fixed with the
following :
case Types.BLOB:
Blob blob = rs.getBlob(columnNumber);
if (blob != null) {
valueObject = blob.getBytes(1, (int) blob.length());
} else {
valueObject = null;
}
break;
Regards.
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org
Re: Antwort: Village
Posted by Xavier Maysonnave <xa...@omondo.com>.
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
Another Village
Posted by Fl...@deuka.de.
Sorry Xavier!
You're absolutely right! I thought you point at your code :-o
Nevermind
Florian Fray
Re: Antwort: Village
Posted by Xavier Maysonnave <xa...@omondo.com>.
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;
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
Antwort: Village
Posted by Fl...@deuka.de.
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