Iterate over java array list and update database

One Star

Iterate over java array list and update database

Hi,
I have a scenario where I need to iterate over java arraylist and then I need to update database table for each entry in the arraylist. Fore each record I need to lookup other tables as well. Therefore the iterated record should be passed through a tMap as well. Can someone please let me know what are the components and how to arrange them in order to get this done?
Thanks and Regards,
Asanka. 
Community Manager

Re: Iterate over java array list and update database

on tJava component, get each item from arrayList and append each item to a string, the final string looks like:
...
String items="a,b,c,...";
And then, store the string to a global var or context var for used later.
On next subjob, generate this string on tFixedFlowInput (get the value of global var or context var), normalize the input string with tNormalize component to generate multiple lines, and then map the lookup data.
tJava
   |
onsubjobok
   |
tFixedFlowInput--main--tNormalize--main--tMap--main--tDatabaseOutputComponent
                                                            |
                                                         lookup
                                                            |
                                                          table
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Highlighted
One Star

Re: Iterate over java array list and update database

Hi Shong,
Thanks for your reply. But this wont help in my scenario as there are millions of records in the arraylist and those records represents a custom object (not strings). Is there a way to iterate the list and process each record (each item of the list) through tMap?
Thanks and Regards,
Asanka.
Community Manager

Re: Iterate over java array list and update database

Hi Asanka 
This is just a simple example with basic data type. For complex type, like custom object in you case, you can use tJavaFlex to iterate the list and process each record.
BR
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads