Forum Discussion

eliasen's avatar
eliasen
Occasional Contributor
5 years ago

databaseConnectionContainer missing in groovy in readyapi?

Hi I have an old soapui-proejct, that I am trying to bring to life again. I ahve installed readyAPI 3 and I get this error when I am trying to run my test: Mon Jan 20 12:23:43 CET 2020: ERROR: An e...
  • Radford's avatar
    5 years ago

    I believe that I hit the same issue as you when I upgraded Ready API from 1.7 to version 2.8.2 (I'm not sure at what point the actual removal of the getDatabaseConnectionByName(java.lang.String) method happend).

     

    I switched my Groovy Script to use the GroovyUtilsPro object to get the JDBC connection, something like the following code:

     

    import com.eviware.soapui.support.GroovyUtilsPro
    
    def groovyUtilsPro = new  GroovyUtilsPro(context)
    def jdbcConnection = groovyUtilsPro.getJdbcConnection('YourConnectionName')

    The GroovyUtilsPro object deals with working out if you are running in the environment mode or not and always returns the correct connection, which I also found very useful.

     

    (Full disclosure, I don't actually use the getJdbcConnection() method as I was actually only using the connection to get a Groovy Sql object, the GroovyUtilsPro actually also provides a getGroovySql() method)