a

a

Integrating JAVA classes in Informatica




Integrating JAVA classes in  Informatica

As a tool Informatica provides many features , and support to Java classes is one of them . We can write our business logic in our favorite language (Java) and can call methods in one of the transformation called Java Transformation . Below exercise is small demo for

  • Writing Small Java class with one method ( use any your favorite java editor ,I prefer Eclipse  Kepler).
  • Wrapping it up in JAR file .
  • Write simple mapping to call above method with Java transformation.

Writing Small Java class with one method

 We are accepting a simple Month number and method will return string with its name .we will use Java transformation to accept parameter for Java method



First create a small java method , here for example  i am writing a method which takes a number as parameter and returns a corresponding months for test .

Then as we need Jar for it lets export it to create Jar using file -> Export menu in eclipse

You will get JAR file at the location you mentioned in above Wizard..


 
Informatica Implementation
Now let’s move to informatica part , write small mapping where we need source with at least one port with number ( which we can use as input parameter to our method ) and in target we should have one string output.
I am going to use target and source as Oracle tables you can use anything of you choice.
As defined above I have created 2 tables one will have only number and other will expect corresponding month name like below

Now simple mapping I will write as below
Here Java transformation is very important to analyze.
First we have to import jar we created in java transformation as below.
Go to edit java transformation click on settings and select the jar from browse button and then click add button.
Now import all packages from jar ( We are having one class only ) in import Package tab as below.
Now let’s call our method to convert number to corresponding Month.

And we are good to now compile the java code .
Now Most important to set class path of the Jar at session level .
We can set it in all different places also for that refer Help of Java Transformation .
Go to session and set class path.
Now run the workflow .
As you can see below reader thread read 12 rows and write written 12 rows in target table Month_char.
Now check our both tables in oracle.

That’s All Folks J