Five Stars

Load Variable from Database and assign to Context variable

I tried to Load value from database and set in a context variable.

I have a table DatabaseConfig and two column (key,value).

Created two context in my job as key and value.

When i try to run the job, the output i am receiving is null

1 ACCEPTED SOLUTION

Accepted Solutions
Nine Stars

Re: Load Variable from Database and assign to Context variable

Hi Dinesh,

 

Are you looking read context values from DB and assign to context variables in job?

 

DB ContextValues.PNG

 

For this you need to define context variable name is same as key value in database.

Here key value is day, so you need to define context variable name as day. Then tContextLoad will assign value (monday) to context "day" 

 

DB ContextValues1.PNG

 

Hope this helps you.

 

Regards,

 

Veeru Boppudi
8 REPLIES
Forteen Stars TRF
Forteen Stars

Re: Load Variable from Database and assign to Context variable

Hi,

Can you share your job design?

At least, which components are you using?


TRF
Five Stars

Re: Load Variable from Database and assign to Context variable

I attached my job design.

Forteen Stars TRF
Forteen Stars

Re: Load Variable from Database and assign to Context variable

It should work.

Double check variables name in your tJava component.

Also verify columns name in SQL schema are aligned with context variables name defined for the job.

 


TRF
Five Stars

Re: Load Variable from Database and assign to Context variable

I have attached 4 files.

-> Database table

-> Context variable for my Job

-> SQL Input connection page

-> Page where to load context detail from DB.

Could you check this and let me know for any further information

Forteen Stars TRF
Forteen Stars

Re: Load Variable from Database and assign to Context variable

What's in your tJava component?

What's in your tMSSqlInput component? Should have 2 fields, not 3 as there in the table.


TRF
Five Stars

Re: Load Variable from Database and assign to Context variable

I am getting output as :

 

Starting job DatabaseJob at 16:57 30/03/2018.

[statistics] connecting to socket on port 3429
[statistics] connected
Implicit_Context_Context set key "days" with value "monday"
Warning: Parameter "days" is a new parameter of Implicit_Context_Context
Warning: Parameter "Key" has not been set by Implicit_Context_Context
Warning: Parameter "Value" has not been set by Implicit_Context_Context
tContextLoad_4 set key "days" with value "monday"
hi


DatabaseJob

[statistics] disconnected
Job DatabaseJob ended at 16:57 30/03/2018. [exit code=0]

 

 

tJava i am printing :

 

System.out.println("hi");

System.out.println(context.Key);
System.out.println(context.Value);
System.out.println(jobName);

Five Stars

Re: Load Variable from Database and assign to Context variable

databasepage -> this jpg which i attached is tMSSqlInput component.

Ok i changed my Database table to two columns. 

Nine Stars

Re: Load Variable from Database and assign to Context variable

Hi Dinesh,

 

Are you looking read context values from DB and assign to context variables in job?

 

DB ContextValues.PNG

 

For this you need to define context variable name is same as key value in database.

Here key value is day, so you need to define context variable name as day. Then tContextLoad will assign value (monday) to context "day" 

 

DB ContextValues1.PNG

 

Hope this helps you.

 

Regards,

 

Veeru Boppudi