Random number genaration

One Star

Random number genaration

Hi,
I am new to Talend, I am working on open studio tool, I would like to generate a number with in the numbers.
The number are starting from 0000 to 9999, with in the number find out the not in sequence number and generate the new number, it is in DB2. Please help me out.
Thank you,
Praveen
One Star

Re: Random number genaration

Hi
for this you can use random number generator in java
java.util.Random (package)
// for generating random number for the range b\w 0000 to 9999
int randomInt = randomGenerator.nextInt(9999)
One Star

Re: Random number genaration

Thank you - Lijo,
And I have one more question about on the same scenario, I would like to check the available numbers ( 0000 to 9999 ), If not available number in between ( 0000 to 9999 ) generate the new number. Could you please help me out?
Thank you,
Praveen
One Star

Re: Random number genaration

Hi Praveen
Are you storing to numbers in the database?, if yes you can put a query else
you can save the numbers to an arraylist and then check if it contains
boolean blnFound = arrayList.contains("2")
Hope it helps you