Forum Discussion

sanathkd's avatar
sanathkd
Occasional Contributor
5 years ago

Creating databaseConnectionContainer in readyapi using groovy script

I know below groovy scripts are used to get JDBC details from the ReadyAPI tool.  ======================================== jdbcName = context.testCase.testSuite.project.databaseConnectionContainer....
  • SunilDevasya's avatar
    5 years ago

    sanathkd :
    You can create using below lines :

    //Get test env where you require changes.
    def env=testRunner.testCase.testSuite.project.getEnvironmentByName("EnvName")
    
    //Get getDatabaseConnectionContainer for that environemnt.
    dbContainer= env.getDatabaseConnectionContainer();
    // Add new connection
    def connection = dbContainer.addResource(conName)
    //Set all properties.
    connection.setDriver(driver)
    connection.setConnectionString(conString)
    connection.<AnyOtherProperty>()


    Thank you,
    Sunil Devasya