EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  connect with db2 database using connect() function

    Posted 08/03/15 08:21 AM

    Hello, im trying to connect to db2 using connect() functon like I did with sql database something like the code below:

     

       dbConnectionString string = "jdbc:sqlserver://SERVER:1433;databaseName=XXX"              
    function blabla()   
    try
           SQLLib.connect(dbConnectionString, "sqlJNDIName", "PW");
           get SearchRec  with 
         #sql
             .............. 
        end

    endend

     SQLLib.connect(dbConnectionString, "DBUSER", "DBUSER_PW");

    Fyi my project is an egl richui application. Do you think it's possible?

    michaeldefox


  • 2.  Re: connect with db2 database using connect() function

    Posted 08/03/15 09:20 AM

    Hi,

    Yes...it is possible in EGL... as the majority of our users are Db2 users.

    You don't issue the sqllib.connect in the RUI itself, but instead you issue it in in the services that the RUI's invoke.

     

    For Db2, if you are using a datasource (JNDI name), your connection string should be the JNDI name that you want to connect to.   If you are not using a datasource, the connection string should be the valid URL used to connect to Db2 (either using Db2 drivers or JT400 drivers (if on IBM i)).

    take care.

    Mark

     

    markevans


  • 3.  Re: connect with db2 database using connect() function

    Posted 08/04/15 06:03 AM

    Will you give me an example with code also?

    Thanks in advace!

    michaeldefox


  • 4.  Re: connect with db2 database using connect() function

    Posted 08/04/15 08:28 AM

    Your code is the example except you need to change the connection URL.   Nothing is different between connecting to DB2 vs SQL Server in the language.

     

    What have you tried?  

     

    Assuming you need to use a datasource since this is a RUI->Service based system, the code is simply

     

     dbConnectionString string = "jdbc/MYDB2DB"  ;           

    function blabla()   
    try
           SQLLib.connect(dbConnectionString, "UID", "PW");
           get SearchRec  with 
         #sql
             .............. 
        end

    end

    You still have to define the datasource with a JNDI name of jdbc/MYDB2DB in your server.   See the EGL helps on this.

     

    markevans