How to call a Java Program from DSTx map

Formally known as "Mercator Inside Integrator 6.7", DataStage TX enables high-volume, complex transactions without the need for additional coding.

Moderators: chulett, rschirm

Post Reply
aviroops
Participant
Posts: 3
Joined: Wed Jan 19, 2011 3:25 am
Location: Pune

How to call a Java Program from DSTx map

Post by aviroops »

Hi,

I have a java program that generates random alphanumeric character.

Code: Select all

import java.lang.*;
import java.util.*;

public class bmid
{

  public static final void main(String args[])
  {

   char AB[] ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	Random rnd = new Random();
	int len = 20;
	StringBuilder sb = new StringBuilder( len );
	for( int i = 0; i < len; i++ ) sb.append( AB[ rnd.nextInt(AB.length) ] );
  	String test = sb.toString();
  	System.out.println(test);

   }
}
once I execute the .class file I get a series of 20 random alphanumeric characters.

Now, I want to redirect the output of this program to one of my field in the output card of my DSTx map.

After a lot of finding i figured out that I need to use GET function along with JAVA adapter.
But i donot know the exact syntax. Been working on this for a week or so but couldnt find any solution.

Can somebody please help me out.
Thanks in advance..
Cheers
Aviroop
aviroops
Participant
Posts: 3
Joined: Wed Jan 19, 2011 3:25 am
Location: Pune

Got the Solution

Post by aviroops »

I finally found out the solution for my own problem.

I did modify the java program a bit.

Code: Select all

import java.lang.*;
import java.util.*;


public class bmid
{

  public static final void main(String args[])
  {
                bmid ob = new bmid();
	ob.randomStr();

  }

public static String randomStr ()
{
  char AB[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  Random rnd = new Random();
  int len = 20;
  StringBuilder sb = new StringBuilder( len );
  for( int i = 0; i < len; i++ ) sb.append( AB[ rnd.nextInt(AB.length) ] );
  String test = sb.toString();
  System.out.println(test);
  return test;
}

}
The file name is bmid.java and was compiled as bmid.class

In the output card of the DSTx Map I have used the following code:

Code: Select all

=GET("JAVA", "-T","<bmid inherited=""no"" returnFields=""no"" this=""randomStr"" ><Constructor></Constructor><Methods><randomStr type=""java.lang.String"" returnValue=""yes""></randomStr></Methods></bmid>")
This code is self explanatory.
If you have any doubt please let me know.
Cheers
Aviroop
Post Reply