Different results running the same job on Windows and Linux

One Star

Different results running the same job on Windows and Linux

I created a Talend job which imports data from a SQL database into a TMS database.
During this job, a varchar field is translated into an integer field. This is done in two steps: First I check if the varchar field is an Integer and if it's true, I convert it, else it becomes 0 (zero).
To do this, a piece of code is used:
package routines;
public class MyRoutines {
public static Boolean isNumeric(String str) {
if(str.equals("")){  return false; }
for(int i=str.length();--i>=0;){
int chr=str.charAt(i);
if((chr<48&&chr!=46&&chr!=45&&chr!=44)|| chr>57)   return false;  } return true;   }}

This is in my tMap:
MyRoutines.isNumeric((Relational.ISNULL(row1.WagenparkNummer)?"a":row1.WagenparkNummer))?Integer.parseInt(row1.WagenparkNummer):0

I created the job with Talend 5.1.2.r90681 and tested it on Windows 7.0. A random record says '001554' in SQL. After conversion the field is saved as 1554 in the TMS database.
I exported the job and extracted the zip file on a Linux system. (Nothing special, I have done this before for around 40 jobs).
And now the strange thing: After running the job on Linux, the same record is converted to 15 instead of 1554.
Why???
Edit:
It only effects records with leading zero's. Records without leading zero's are converted in the correct way.
(Example given: '002534' is converted wrongly to 25. '2534' is converted to 2534.)
Screenshots: First subjob clears the output database. The second subjob retrieves information from a SQL server, convert some fields and store the result in the output database Kewill.
One Star

Re: Different results running the same job on Windows and Linux

The field in the output table is a Numeric field. (Not signed with +/-, so negative numbers are impossible). Via ODBC the numbers are inserted in the correct way. Via JDBC the numbers are inserted in the wrong way. If I change the numeric field into a signed numeric field (in the output table), the numbers are inserted in the table in the correct way via both JDBC and ODBC.
Community Manager

Re: Different results running the same job on Windows and Linux

Hi
Can you make a testing to use a tLogRow or tFileOutputDelimited instead of TMS database to see if the conversion is correct? In addition, to check a string value if it is a numeric type, you can use built-in function Mathematical.NUM("string"), for example:
Mathematical.NUM((Relational.ISNULL(row1.WagenparkNummer)?"a":row1.WagenparkNummer))==1?Integer.parseInt(row1.WagenparkNummer):0

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Different results running the same job on Windows and Linux

I have tried different things. Read this thread (More active than this forum).
The conversion is correct. I tried a different input (.csv file), same different results.
I tried a different output (.csv), both (Windows/Linux) work correctly.
I changed the field type to Signed, instead of Numeric in the TMS table. It did not work 100%, instead of 1554 to 15, I now see 155 as result.
If I use Talend Studio for Windows, all works correct. If I use the Talend Job, run from the linux prompt, it goes wrong.
Community Manager

Re: Different results running the same job on Windows and Linux

Hi 
I tried a different output (.csv), both (Windows/Linux) work correctly.
I changed the field type to Signed, instead of Numeric in the TMS table. It did not work 100%, instead of 1554 to 15, I now see 155 as result.

So, the problem only occurs during the insertion into TMS database. I see you mentioned it is GNU libgcj java 1.4  on Linux system, you must have different java versions on Windows and Linux system, Talend product requires Oracle java 1.6 or higher, try to install Oracle java on Linux system. I don't know what is your TMS database, however, a workaround to resolve this issue could be: check the string record if it starts with 0, if true, remove the leading 0 and convert it to Integer type before inserting it to TMS database.
Best regards
Shong 
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Different results running the same job on Windows and Linux

I asked the sysadmin to install version Java RE 1.7 in a seperate directory, so I can try this.
The machine is running Redhat 5.5