Forum Discussion

eliasen's avatar
eliasen
Occasional Contributor
5 years ago
Solved

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 error occurred [No signature of method: com.eviware.soapui.impl.wsdl.support.connections.DefaultDatabaseConnectionContainer.getDatabaseConnectionByName() is applicable for argument types: (java.lang.String) values: [test]], see error log for details

 

My script has this line:

import groovy.sql.Sql

Class.forName("oracle.jdbc.driver.OracleDriver")
connection = testRunner.testCase.testSuite.project.databaseConnectionContainer.getDatabaseConnectionByName('test')

 

when I edit the script, I can see in the editor, that the "project" doesn't seem to have an entry for "databaseConnectionContainer" anymore. I just don't know what to change it to - I have searched all I can think of, for a fix. 

Any hints/pointers?

 

Thanks

  Jan

  • 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)

3 Replies

  • Radford's avatar
    Radford
    Super Contributor

    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)

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Thank you Radford.

      eliasen did you have a chance to try this approach? Do let us know. Thanks.

    • eliasen's avatar
      eliasen
      Occasional Contributor

      Thanks, Radford :-)

       

      That got me a step closer to a working script :-)