DavidEtcell
12 years agoOccasional Contributor
How to get values to properties using a Groovy DataSource?
Hi Everyone,
I I am using a groovy datasource, and can not figure out how to get the values returned from the database into the properties.
This is setting up the connection, this always remains the same:
This returns a closed recordset which I can not seem to get anything out of, so I dont use it
This returns a list of arrays of values
Say the call to the database returns 2 rows of 3 columns.
If I use something like the following:
when it asks to 'specify number of rows to get', the number i enter i get in rows of '[Column1Name.Row1,Column1Name.Row2]' (arrays of all values.) Also, if I make this '0' it runs for infinity and I have to manually end the SoapUI Pro process with Task Manager.
My real question though, is how do I load the properties of the datasource so each property contains different values from the database call?
How do I get the datasource to populate 1 record per row?
I I am using a groovy datasource, and can not figure out how to get the values returned from the database into the properties.
This is setting up the connection, this always remains the same:
import groovy.sql.Sql
com.eviware.soapui.support.GroovyUtils.registerJdbcDriver( "net.sourceforge.jtds.jdbc.Driver" )
def sql = Sql.newInstance('jdbc:jtds:sqlserver://HINICMTSTDB:1433/icmpa12s', "<login>", "<password>", "net.sourceforge.jtds.jdbc.Driver")
This returns a closed recordset which I can not seem to get anything out of, so I dont use it
//def res = sql.executeQuery("exec CWB.GetDocumentLink 'HE100196','E9324231'")
This returns a list of arrays of values
def res = sql.rows("exec CWB.GetDocumentLink 'HE100196','E9324231'")
Say the call to the database returns 2 rows of 3 columns.
If I use something like the following:
result["prop1"] = res.Column1Name.toString()
when it asks to 'specify number of rows to get', the number i enter i get in rows of '[Column1Name.Row1,Column1Name.Row2]' (arrays of all values.) Also, if I make this '0' it runs for infinity and I have to manually end the SoapUI Pro process with Task Manager.
My real question though, is how do I load the properties of the datasource so each property contains different values from the database call?
How do I get the datasource to populate 1 record per row?