[resolved] String-->BigDecimal conversion error

One Star

[resolved] String-->BigDecimal conversion error

Hi All
found here :
http://www.talendforge.org/forum/viewtopic.php?id=26333
1. String-->BigDecimal
new java.math.BigDecimal(row1.columnName)
trying to do :
new java.math.BigDecimal(row1.price_txt)
in row1.price_txt (DB table) all values : '1234'
get error :
Exception in component tMap_1
java.lang.NullPointerException
at java.math.BigDecimal.<init>(Unknown Source)
at thinkbi_dev.j_context2_test_0_1.j_context2_test.tOracleInput_1Process(j_context2_test.java:1952)
at thinkbi_dev.j_context2_test_0_1.j_context2_test.runJobInTOS(j_context2_test.java:3268)
at thinkbi_dev.j_context2_test_0_1.j_context2_test.main(j_context2_test.java:3020)
Any ideas ?
1952 java code string
out1_tmp.p_bigdec = new java.math.BigDecimal(
row1.price_txt);

Accepted Solutions
One Star

Re: [resolved] String-->BigDecimal conversion error

Yes it was null- I forget to include it in query
though added maunally in scheme
So in DB table it was filled but Null in Talend

All Replies
One Star

Re: [resolved] String-->BigDecimal conversion error

Hi,
Probably your String is null sometimes. To avoid an NPE you could use a structure like this:
row1.price_txt != null ? new java.math.BigDecimal(row1.proce_txt) : null;
Hope this helps.
Regards,
Arno
One Star

Re: [resolved] String-->BigDecimal conversion error

Yes it was null- I forget to include it in query
though added maunally in scheme
So in DB table it was filled but Null in Talend