Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello !
how can I retry a database connection once the first time it failure ? I mean, is there a kind of loop to keep trying connecting the database until a success connection?
Best Regards!!
Hello, I could solve the problem:
this is the correct code:
try{
if ( ((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION"))!=null&&((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")) > 1)
{
Thread.sleep(10000);
}
}catch(Exception e){
if (((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION"))!=null&&((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")) > 50)
{
context.continueLooping = false;
}
else
{
System.out.println("Tentativa n°: "+((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")));
}
}
You can establish a loop to determine if the connection to database is successful. You will find more info in the below link.
https://www.barmartland.com/retry-failed-connections-in-talend/
hello,
tks!
I don't know What I am doing wrong I have followed all instruction but I got this errors
Starting job Customers at 12:16 03/05/2019. [statistics] connecting to socket on port 3822 [statistics] connected Exception in component tJavaFlex_2 (Customers) java.lang.NullPointerException at local_project.customers_1_0.Customers.tLoop_1Process(Customers.java:790) at local_project.customers_1_0.Customers.tJava_1Process(Customers.java:482) at local_project.customers_1_0.Customers.runJobInTOS(Customers.java:1220) at local_project.customers_1_0.Customers.main(Customers.java:1054) [statistics] disconnected Job Customers ended at 12:16 03/05/2019. [exit code=1]
I am using this code:
// start part of your Java code
try{
// here is the main part of the component,
// a piece of code executed in the row
// loop
if (((Integer)globalMap.get("tLoop_1_CURRENT_INTERATION")) > 1)
{
Thread.sleep(1500);
}
// end of the component, outside/closing the loop
}catch(Exception e){
if (((Integer)globalMap.get("tLoop_1_CURRENT_INTERATION")) > 5)
{
context.continueLooping = false;
}
else
{
System.out.println("Connection failed. Retrying..");
}
}
Hello, I could solve the problem:
this is the correct code:
try{
if ( ((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION"))!=null&&((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")) > 1)
{
Thread.sleep(10000);
}
}catch(Exception e){
if (((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION"))!=null&&((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")) > 50)
{
context.continueLooping = false;
}
else
{
System.out.println("Tentativa n°: "+((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")));
}
}