Database Connection URL - using global variables

Hi,

is there any possibility to use global variables in Database Connection URL?
I found this topic from 2018 Parameterize Global Connection URL of Database - #3 by Mathew.Kuruvila, but without any reponse.

This feature is key to DDT due to need the test environment.

For example:
First enviroment: jdbc:oracle:thin:AAA/AAAA@XXX:1530/AAAA
Second environment: jdbc:oracle:thin:BBB/BBB@XXX:1530/BBBB

We really need to switch them accoring to actual execution profile like this:
jdbc:oracle:thin:${user}/${password}@${server}:1530/${database}

Thanks you.

Any suggestions?

Any suggestions?

Hey Petr @petr.brezina, thank you for bringing up this topic. Based on the documentation, KS currently does not support parameterize Global Variables for Database Connection URL. For now, you could follow the advice from the post you found to help switch between different databases. You can suggest this feature here if you want it to be added for later releases.

Hope this answer your question!

I use a few Global Variables to set up my logon to different test environments, like DEV, BASE, TEST, etc. within my Profiles. (We sometimes need to close off one environment for specific tests). So, I would think you could have a different set of URL connection strings for each of the same Global Variables you have within your different environments.

Maybe like:

You could create Profiles called ORA and ORB, and within each Profile, create (or copy and paste) your four Global Variable Strings, like:

  1. in the ORA Profile:
    gUser | String | AAA | The user connection phrase
    gPassword | String | AAAA | The password connection phrase
    gServer | String | XXX | The server connection phrase
    gDatabase | String | AAAA | The database

  2. in the ORB Profile:
    gUser | String | BBB | The user connection phrase
    gPassword | String | BBBB | The password connection phrase
    gServer | String | XXX | The server connection phrase
    gDatabase | String | BBBB | The database

Hi,

thanks for your reply.

Yes, your solution is possible, but only for the custom connection to DB (using DBMS plugin or custom keyword). It’s not possible to use with a native Katalon DB connection like this:


There is no option to put variables to connection URL.

I would like to have only one Database Connection and Query Settings for more DB enviroments like this:

How about multiple projects that have a different connection string for each project? You could copy and paste the Test Cases, etc. that is necessary for your project between the various project folders, even creating a bat or cron file to copy the files or directories you want. Or multiple installs of KS until the “new” feature you ask for is added in a later release.

Thanks for your reply and tips and tricks.
I am not sure if this feature will be added in a later release. There are some topics that calls for variables is connection URL from 2018 and and no one has yet confirmed it from the Katalon Studio team since then.

Test data files are stored in your project, in plain xml files, under the Data Files folder.
E.g for a given mysql connection, I have the following content in New DB connection.dat

<?xml version="1.0" encoding="UTF-8"?>
<DataFileEntity>
   <description></description>
   <name>New DB connection</name>
   <tag></tag>
   <containsHeaders>true</containsHeaders>
   <csvSeperator></csvSeperator>
   <dataFileGUID>4faa5823-bc5d-487f-8ccd-90a2c354e51e</dataFileGUID>
   <dataSourceUrl>jdbc:mysql://localhost:3306/DB_NAME</dataSourceUrl>
   <driver>DBData</driver>
   <driverClassName></driverClassName>
   <isInternalPath>false</isInternalPath>
   <password>c29tZXBhc3M=</password>
   <properties>
      <entry>
         <key>readAsString</key>
         <value>false</value>
      </entry>
   </properties>
   <query>SELECT * FROM sometable;</query>
   <secureUserAccount>true</secureUserAccount>
   <sheetName></sheetName>
   <user>someuser</user>
   <usingGlobalDBSetting>false</usingGlobalDBSetting>
</DataFileEntity>


The password field is not encrypted, is just a base64 encoding (feel free to decode mine)
So, you can override such, before running your tests in the pipeline with KRE, by a pre-run script (either parse the file and replace whatever you need or produce it from a template)