Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
TXAggie00
Contributor III
Contributor III

Referenced joblet - Changing Dynamic Component List for DB connections

Hello all,

 

I have a global project that is setup as a referenced project and is referenced in every project we create.  This project initially just held all the metadata for all of the various databases, tables, views, connection contexts for all three environments, etc.

 

There is now a need to port some code into joblets since this code should be used across most projects.  This job has various DB tables that are being brought in for lookups, etc.  I have set the connection for these DB inputs as "Use an existing connection".  I leave the component list blank and define the component list in the Dynamic Settings and set it to an arbitray "tMSSqlConnecion_1".  Since this job will be used in various places throughout various projects, this should not be a hard-coded value, since the tPreJobs in these projects may define the connection in an arbitrary order.  It seems as though when I bring in the joblet into another project, I am unable to change the dynamic list value to the necessary db connection component.  In one job it is the tMSSqlConnection_1 and in another job it is tMSSqlonnection_3, for instance.  I certainly do not want to tell the rest of the development team, that, if you need to use this joblet, you HAVE to setup the connection in the tPreJob in a very specific way in order to satisfy this rather static requirement.  My next thought was to use a context variable in the joblet as an object so I can dynamically update the context variable to point to the specific connection component, but I get a NPE at the very first sql input component.

 

Exception in component jlet_DataHubPolicy_Upsert_1_tMSSqlInput_1
java.lang.NullPointerException

 

So long story short, how can I make a referenced project joblet flexible enough to be used in other projects without hard-coding a specific connection component?

 

Thanks,

Scott

Labels (4)
1 Reply
TXAggie00
Contributor III
Contributor III
Author

I have also run into an additional issue:

When I drop the referenced joblet onto the job, it uses the project name and the joblet name for all the java code that gets generated.  This causes all sorts of havoc in the code.  For instance, this is the code for the one of the error functions that was created:

 

public void DataHub-Common:jlet_DataHubPerson_Upsert_1_tJavaRow_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException {
     end_Hash.put(errorComponent, System.currentTimeMillis());
     status = "failure";
    tMSSqlCDCInput_1_onSubJobError(exception, errorComponent, globalMap);
}

Obviously, java does not like the characters in that naming convention.  I don't remember this being an issue in the past.  Anyway around this issue?

 

BTW, I am using version 6.3 and the client is apprehensive about upgrading due to the number of issues moving from 6.2 to 6.3 caused.

 

Thanks,

Scott