简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM