Forum Discussion

gpeeters's avatar
gpeeters
Occasional Contributor
12 years ago

Database connection per environment

Dear Support team,

It is possible to specify service endpoints per environment
For global database connections it seems that it is not possible.

How can I specify which database connection have to be used based on the selected environment?

We have 3 environments

dev, test and stage.
Each environment has its own database.
I need database access to retrieve userID and tokenId

Kind regards,

Geert Peeters

1 Reply

  • Hello,

    Unfortunately this is a known bug and we are working on fixing it. Bug tracking number: SOAP-1210. Below is a work around that you can place in one of the event handlers on the Project level. If you have further questions please let me know.


    /* Work with more than one JDBC connection set per environment, also does not modify connection strings when JDBC TestStep is not configured using a Project-Level JDBC connection */

    // Iterate all test steps in the test case and change connectionString for all ProJdbcRequestTestStep to the selected environment connectionString.

    for(testStep in context.testCase.getTestStepList())
    {

    // Set the connectionString for all ProJdbcRequestTestStep
    if(testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.ProJdbcRequestTestStep)
    {
    // Get databaseName
    def databaseName = testStep.getJdbcRequestTestStepConfig().getDbConnectionName()
    if(databaseName != null)
    {

    // Get connectionString of active environment

    def connectionString = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getConnectionString() testStep.setConnectionString(connectionString)

    // Get connection password of active environment

    def connectionPassword = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getPassword() testStep.setPassword(connectionPassword) }

    }
    }


    Regards,
    Temil