I am trying to read data from xml file and write them to Mysql db. In my db House_no field's data type is String(40). In xml file there are some house no values that longer than 40 and i want to cut all the values that are greater than 40.
so i try the code below in tMap but i got "java.lang.StringIndexOutOfBoundsException: String index out of range: 40 at java.lang.String.substring(Unknown Source)" error?
row4.house_no.length()>40 ?"" : row4.house_no.substring(0,40)
Do you have any idea what cause this error, or a better way to take 0-40 character without using tJavaRow.
Try putting you ternary statement in the correct order and add a "null" check to it:
row4.house_no != null && row4.house_no.length() > 40 ? row4.house_no.substring(0,40) : row4.house_no
Talend named a Leader.
Kickstart your first data integration and ETL projects.
Watch the recorded webinar!
Find out how Forrester rate different iPaaS and Hybrid Integration Platforms
Find out about Talend's 2019 Summer release
Talend continues to revolutionize how businesses leverage speed and manage scale