Forum Discussion
DavidEtcell
12 years agoOccasional Contributor
As shown here: http://forum.soapui.org/viewtopic.php?f=5&t=22836, I have attempted to use a JDBC datasource, but it refused to return the results of the stored procedure.
My mistake here though, was assuming that the groovy datasource was a datasource which extended the basic 'grid' class, with a groovy script attached to it. No problem though, I have already solved this problem with just that - a grid datasource and a groovy datasource.
Code for this was:
My mistake here though, was assuming that the groovy datasource was a datasource which extended the basic 'grid' class, with a groovy script attached to it. No problem though, I have already solved this problem with just that - a grid datasource and a groovy datasource.
Code for this was:
import groovy.sql.Sql
com.eviware.soapui.support.GroovyUtils.registerJdbcDriver( "net.sourceforge.jtds.jdbc.Driver" )
def DataSourceStep = testRunner.testCase.getTestStepByName("DataSource3")
def sql = Sql.newInstance('jdbc:jtds:sqlserver://HINICMTSTDB:1433/icmpa12s', "<login>", "<password>", "net.sourceforge.jtds.jdbc.Driver")
def res = sql.eachRow("exec CWB.GetDocumentLink 'HE100196','E9324231'"){
def currentrow = DataSourceStep.dataSource.gridModel.getRowCount()-1
DataSourceStep.dataSource.gridModel.setValueAt(it[0].toString(),currentrow,0)
DataSourceStep.dataSource.gridModel.setValueAt(it[1].toString(),currentrow,1)
//didn't need this after all as there is always an extra 'blank' line at the bottom of the list, meaning as soon as a value is populated in one row, another blank row is added
//DataSourceStep.dataSource.gridModel.insertRows(DataSourceStep.dataSource.gridModel.getRowCount()-1,1)
}