RBD 8.5.1 EGL RUI, Programs, Dedicated Services
I am trying to figure out if it is appropriate (or possible) for a EGL program/service to connect to two different data sources during development and during run time, one DB2 and one Microsoft SQL Server 2008.
Would it be best to use connect() in the code? How does this affect the EGL SQL Connections? What would be the data source configuration for WAS and the EGL projects? Would it be driven from the jdbc entry?
Any help or advise is greatly appreciated.
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
4 replies Latest Post - 2013-02-19T15:51:12Z by JBASkeen
Pinned topic EGL program/service to connect to two different data sources
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-02-19T15:51:12Z at 2013-02-19T15:51:12Z by JBASkeen
markevans 120000NQBF2781 PostsACCEPTED ANSWER
Re: EGL program/service to connect to two different data sources2013-02-15T16:36:01Z in response to JBASkeenJames,
You can connect to multiple databases within a single rununit.
Basically, a rununit has only one default connection. You can use connect() to connect to as many databases as you want, and use SQLLib.setCurrentConnection() to switch between them.. Or connect/disconnect as you go.
Also, each program/service/library/handler has to be generated for a particular database manager, so you'll have to split the access into separate generatable parts in order to access different database manager types.
Assuming you are running as a J2EE app, you would need to define a datasource for each database and then in the connect() function name the appropriate JNDI name associated with the datasource.
For a non-J2EE app, the appropriate URL would be the input to the Connect() function.
I am not sure what you mean by the EGL SQL Connection? do you mean the preferences or the connection at runtime? or something else?
Re: EGL program/service to connect to two different data sources2013-02-18T14:44:23Z in response to markevansMark,
Thanks for your reply. Your explanation makes sense except for the part about splitting the access into separate generatable parts, are you talking about splitting the parts into different projects with the appropriate build options for the connection type? For example, ProgramA connects to DB2 and ProgramB connects to Microsoft SQL. ProgramA would go in an EGL project with build options for DB2 and ProgramB would go in a separate EGL project with build options for Microsoft SQL? Does this mean ProgramA could not connect to both DB2 and Microsoft SQL?
I am attempting to run these projects as J2EE on WAS. By EGL SQL Connection I was talking about the preferences option to set the default EGL SQL Connection on the RBD workbench. If this default connection preference is DB2 can an EGL program still connect to Microsoft SQL without changing this preference? Does the Microsoft server connection just need to be setup as a data source on the workbench, like in the Data perspective?
markevans 120000NQBF2781 PostsACCEPTED ANSWER
Re: EGL program/service to connect to two different data sources2013-02-18T21:42:45Z in response to JBASkeenJames,
On the splitting, I mean splitting the access to DB2 or to Microsoft SQL into different generatable parts (libraries, services/programs). This does not mean they have to be placed is separate projects even though that is one approach as long as the generated code is directed into one web project (to make it simple)
If you don't want to create new projects, then know that an .eglbld file can contain multiple build descriptors. So what I would suggest is to create one build descriptor that specifies the DB2 connection information and another one that specifies the Microsoft SQL information. Then if you have separated the access modules into their own packages...you can define a default build descriptor at the package level (or at least for the one that is "different" than most. Then one particular package will be generated for Microsoft SQL (using that unique build descriptor) and the other package can be generated using the DB2 build descriptor.
To further explain...what build descriptor is used at generation is basically a bottom up search. So, it checks to see if a default build descriptor is defined in this order (.egl file, package, EGL Source, Project, Workspace preference). The first found in that order is used.
The Preferences option to set the default SQL connection is only used to specify which DB to connect to when doing things like SQL Retrieve and for debug if not specified otherwise in the debug build descriptor (I think I am right about this last one). When you want to use SQL Retrieve to define a record, then you do have to switch the current connection in the preferences to the appropriate database.
This also assumes you have defined a database connection to each unique database.
At run time, you will need the datasource/JDBC driver to be defined to the application server for each database.
Re: EGL program/service to connect to two different data sources2013-02-19T15:51:12Z in response to markevansMark,
Your explanations are making sense, now I need to play around with the configuration on my side and see how I can put the puzzle together.
Thanks a bunch,