'Convert negative integer to string Talend open studio

My objective for this Talend Job is to insert the the data from excel into the mysql db. When i input the excel file, the column of Active Case is string which it contains some negative integer.

However, i want to store this as in integer later in the mysql db. The following is the code in Tmap. My want to store all the negative integers in db as well as integer field. What is the issue here even though i parse as int.

`Var.var9==null||Var.var9==""?0:Integer.parseInt(Var.var9)`

Raw Data Excel File

Talend Job

Tmap

Error Message



Solution 1:[1]

If your read Input is null or nothing ("") you insert 0. Anything else is used as a number. The error message indicates that there is a row in your excel which only contains "-". You can easily reproduce this by trying it out like this:

Integer i = Integer.parseInt("-");

You the get the same error message

Caused by: java.lang.NumberFormatException: For input string: "-"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:572)
at java.lang.Integer.parseInt(Integer.java:615)

If your excel really does not contain just a "-" in your parsed data, then you should provide more of your code. The error may be in your parsing process.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1