Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey I have been using talend a little and I want to use it as part of another Eclipse application. Pretty much I want to take a job and call it from another java program. I could use system to do this but, that is not very portable and I need my application to be portable. Is there any good way to use a talend job inside another java program?
I published a first version of the code at sourceforge http://sourceforge.net/projects/talendjobschedu/.
If you have any question please contact me (until I wrote a documentation).
I wrote this article on my blog : http://www.tchogy.fr/2011/03/talend-integration-dans-une-application-j2ee/
It explains how to launch dynamically a job from a J2EE application.
Exception in component tMysqlOutput_1
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "null"'.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:298)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at importationsql.job1_0_1.job1.tFileInputDelimited_1Process(job1.java:712)
at importationsql.job1_0_1.job1.runJobInTOS(job1.java:1212)
at importationsql.job1_0_1.job1.main(job1.java:1066)
at Talend.main(Talend.java:9)
Caused by: java.lang.NumberFormatException: For input string: "null"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at com.mysql.jdbc.NonRegisteringDriver.port(NonRegisteringDriver.java:814)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
... 6 more
Hello lotu
Thanks for your interesting in Talend.
You can not only call a Java program in a Talend job, but also call a Talend job in a Java program. You can simply follow the steps below:
1) Create a simple job in TOS.(see screenshot1)
2) Export the job Java script.(see screenshot 2 and 3)
3) Unzip the Java script file on current folder.
4) Launch Eclipse and create a new Java project, then create a class 'Talend.java'.(see screenshot4)
5) Right click on test and select 'Build Path'-->'Configure Build Path'. (see screenshot 5)
6) Click on 'Add External Jars' button to import the jar file 'myjob_0_1.jar' (under myJob_0.1\myJob_0.1\myJob) and all the jar files (under myJob_0.1\myJob_0.1\lib) (see screenshot 6 and 7)
7) Type in the Java code in class 'Talend.java' (see screenshot 😎public class Talend
{
public static void main(String[] args)
{
shong.myjob_0_1.myJob.main(new String[]{});
}
}
Here you will notice that:
shong: Talend project name
myjob_0_1: jar file name
myJob: Talend job name
😎 Finally, run the Java program.(see the screenshot 9)
Best regards
shong