Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
desanip
Contributor
Contributor

Call Routine from inside Talend Job

Hello Talendians,

Can someone explain me How i can call the user routine within my talend job? Is it just <routine_name>.<method_name>

 

I have created a routine to decrypt my encrypted password. So all i need to do is to use it in my tmssqlconnection password?

 

Thanks in advance.

Labels (3)
9 Replies
TRF
Champion II
Champion II

You got it, in the password field or before the tXxxxxConnection to set a global variable reused for the password

Anonymous
Not applicable

Hi @desanip ,

 

Before the connection component, set the password in a context as context.password = yourDecryptRoutine(enCryptedpassword) and use the context in Connection component.

 

Thanks and Regards,

Subhadip

desanip
Contributor
Contributor
Author

@subhadip13 @TRF 


Thanks for the insights guys.

 

I am attaching a screenshot of the workflow and the routine i am using. I have saved the varible in a tsetglobalvar and was able to print it. I sent the variable( Which is basically a encrypted string) to my routine and i have decrypted it using a java algorithm.

So i am trying to put the decrypted password in tmssqlconnection. 

 

How i do i store the return value from java routine in talend?

 

When i call my routine, the connection component is throwing an error.

Let me know if what i have done looks correct.


2019-06-26_12-55-24.png
error.PNG
Anonymous
Not applicable

Hi @desanip ,

 

As mentioned earlier you can store the result of the decryption to a context and use the context in your connection component.

 

Thanks and Regards,

Subhadip

TRF
Champion II
Champion II

Share the error message
desanip
Contributor
Contributor
Author

Hello @TRF,

 

This is the error message:

 

Valueafterdecryption=Decrypt_Routine.PassingGlobalVar
[FATAL]: tgtimdarenew.dd_0_1.dd - tMSSqlConnection_1 Login failed for user 'tgbi_id00'.
java.sql.SQLException: Login failed for user 'tgbi_id00'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:632)
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:371)

 

I see the following message when i try to call the assign routine return value to my tsetglobalvar. I set it as Key= "Valueaftedecryption", Value= Decrypt_Routine.PassingGlobalVar and then trying to call the global map variable inside my tmssqlconnection component password = ((String)globalMap.get("Valueaftedecryption"))

 

My java routine is:

--------------------------------------------------------------------------------

package routines;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;

public class Decrypt_Routine {

public static String PassingGlobalVar(java.util.Map<String, Object> globalMap) {
// TODO Auto-generated method stub

globalMap.put("SQLServer_password", "****************");

System.out.println("myString=" + globalMap.get("SQLServer_password"));

StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setAlgorithm("PBEWithMD5AndDES");
encryptor.setPassword("***************");

String encryptedValue = "***********************************";

String decryptedValue = encryptor.decrypt(encryptedValue);
System.out.println("Decrypted Value is "+decryptedValue);


return decryptedValue;
}
}
class Decryption{
public static void main(){
Decrypt_Routine.PassingGlobalVar(null);
}
}

-----------------------------------------

 

Please let me know if you see me doing anything wrong

TRF
Champion II
Champion II

Did you check the value of the "Valueafterdecryption" global variable?

Also, the method PassingGlobalVar should have a simple string as the parameter, for example encryptedPassword.

This way, you can call the method with the following expression:

Decrypt_Routine.PassingGlobalVar((String)globalMap.get("SQLServer_password"))

Finally, the routine should be defined as a single Java class, 1 for encryption (parameter = clear password) and 1 for decryption (parameter = encrypted password).

 

 

 

desanip
Contributor
Contributor
Author

@TRF,

I did and it was returning the string "Decrypt_Routine.PassingGlobalVar" which is incorrect. I needed the return value of the decrypyed string. Clearly the classname.routinename call is not working.
TRF
Champion II
Champion II

I've just completed my previous post