Search code examples
javamysqltalend

Talend - Reading value from tHashImport component in Java application - HowTo?


I am new in Talend and currently I am writing my first Talend job.

I am doing the following:

  • Query one MySQL db table (SELECT * FROM docs WHERE DocName = 'XYZ') which will return few records using tHashInput
  • Store these records in memory using tHashOutput
  • Fetch these records from memory using tHashInput
  • and log the records using the tLogRow component

I am running this Talend job from Java application like this:

FetchDocuments mySQLConnectorJob = new FetchDocuments();
mySQLConnectorJob.runJob(new String[]{});

And at the end I would like to fetch these records somehow in the Java application, for example with some method:

mySQLConnectorJob.getResultSet();

I know that we can store these records in the CSV file using the tFileOutputDelimited component and then to parse that file in the Java application to fetch records, but I would like to avoid using that file if it is possible.

My questions:

  1. Do you know maybe how I can fetch records in the Java application and finish this task?
  2. If my design on Talend job is not good, could you provide me some advice how to change it to be able to finish task?

Thanks, Nenad


Solution

    1. You could store the records in an instance object of mySQLConnectorJob using tJavaFlex or tJava. Then get those values from the instance object.