Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
You got it, in the password field or before the tXxxxxConnection to set a global variable reused for the password
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
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.
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
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
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).
I've just completed my previous post