[resolved] How to take the value from tHashInput component ?
Hi,
which options we have when we want to fetch value (one db table record fetched using tMysqlInput) from tHashInput component when Talend Job is started in Java application?
I know that we can store that record in some CSV file for example using tFileOutputDelimited and parse the file later, but is there any other options how can fetch this value in Java application without writing record in the file first?
If it is possible, providing small Java snippet of fetching DB record which is stored in tHashInput would be very helpful.
Thanks,
Nenad
Hi all, I found the way to store values from tHashInput component to globalMap object and to fetch these values in Java application. So after tHashInput component I put tJavaRow component. In tJavaRow component I created new HashMap and inside that map I put db table record. After that I put that HashMap instance to globalMap in the same jJavaRow component. //Instantiate metadata Map
java.util.Map<java.lang.String, java.lang.Object> docMetadata = new java.util.HashMap<java.lang.String, java.lang.Object>();
globalMap.put("docMetadata", docMetadata); metadata1 is connection name from tHashInput component to tJava component. When I started job in Java application I fetched globalMap using Java reflection.
Hi Sabrina,
thank you for your answer.
I am already using tHashOutput component to store data in memory and after that tHashInput to read data from memory. This job I started from Java application. But missing part for me is
how I can fetch that data from tHashInput component in Java application, is there any method on job object that I can use to fetch that data? Please note that I am new in Talend and this is my first Talend job. Basically I am reading record from MySQL DB using tMysqlInput , store that result in memory using tHashOutput, fetching that using tHashInput and loging result using tLogRow component. I will attach my job to this post. If you see something that is not logical in design please let me know.
So the question is how I can read tHashInput data in Java application? Please give me example if it is possible.
Hi janhess,
I can start job and in the logs I see results, but how I can take these records in Java application?
I want to take db record and place it in some Map to be able to process it later? What is the right way to do it?
Thanks,
Nenad
After tHashInput connection to tMap, how I can fetch that Map in Java code? I am starting job like this: FetchDocuments mySQLConnectorJob = new FetchDocuments(); mySQLConnectorJob.runJob(new String[]{});
Client asked Talend to be included in architecture. They want to be able to change some things, so I have to use Talend. Do you know maybe how I can take values from tMap in Java application? Is there any way to do it? I just tried to find some getter of tMap in Talend object but without success.