Solved
Forum Discussion
3 Replies
Sort By
- TNeuschwangerCommunity Leader
Hello chirangv
import groovy.sql.*; import com.eviware.soapui.support.GroovyUtilsPro; def jdbcConnectionName = "your jdbc name defined in environment configuration page"; //log.info " jdbcConnectionName=$jdbcConnectionName"; def groovyUtilsPro = new GroovyUtilsPro(context); def sqlConnection = groovyUtilsPro.getJdbcConnection(jdbcConnectionName); def sql = Sql.newInstance(sqlConnection); def sqlQuery = """ SELECT colname FROM tablename WHERE colname = 'something' """.toString(); log.info " sqlQuery=$sqlQuery"; dbRows = sql.rows(sqlQuery); log.info " dbRows.size()=${dbRows.size()}"; assert dbRows.size() > 0, "Need a row returned but none was... No data found."; dbRows.each { row -> log.info " row.id=${row.id}"; };
- chirangvNew Contributor
Thank you
- adamjoyOccasional Contributor
In order to access the database connection string dynamically in your Groovy test step. You can retrieve it based on the active environment from a properties file or a central configuration service.
I found this approach particularly useful in systems leveraging Edge Computing, where database interactions often need to be secure and environment-specific. As proper encryption and secure storage of connection details are important to address security challenges in edge computing effectively.