DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
This topic has been marked "Resolved."
Author Message
aviroops
Participant



Joined: 19 Jan 2011
Posts: 3
Location: Pune
Points: 45

Post Posted: Wed Jan 19, 2011 3:50 am Reply with quote    Back to top    

DataStage® Release: 8x
Job Type: TX
OS: Windows
Hi,

I have a java program that generates random alphanumeric character.
Code:

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



Joined: 19 Jan 2011
Posts: 3
Location: Pune
Points: 45

Post Posted: Wed Jan 19, 2011 7:17 am Reply with quote    Back to top    

I finally found out the solution for my own problem.

I did modify the java program a bit.
Code:

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:

=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
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours