Ask a Question

Iterate rows in JDBC Data Source

jkrier
Regular Contributor

Iterate rows in JDBC Data Source

Does anyone know how to iterate over the result set returned by the JDBC Data Source? I can only seem to get the last row in the set.

 

This is what I have come up with so far

 

def var = testRunner.testCase.testSteps['DataSource']
def rowCount = var.rowCount as int
log.info "ROW COUNT = " + " " + rowCount
for ( item in rowCount ){
		log.info var.getProperty('systemId').value
}

This will only return the very last row in the query results.

 

In my project I have 3 Data Sources. The second Data Source is the one I want to iterate through. I want to collect some values, pass them into a Properties step and then validate a subsequent Soap response against these values.

 

I can't think of a way to do this using Data Source Loops, which I am using for the other two Data Sources but the middle Data Source is not being used for gather inputs, I just want to validate a response later on based on the query results.

4 REPLIES 4
nmrao
Community Hero

Here some script done earlier based on the data provided by user. May be this gives an idea to get started with.

 

https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/compare/xmlAndJdbc_sample1.groovy

 

https://github.com/nmrao/groovyScripts/search?utf8=%E2%9C%93&q=ResultSet&type=

 

 



Regards,
Rao.
jkrier
Regular Contributor

Thank you @nmrao for your response. I am not using a JDBC Request step I am using the JDBC Data Source so the response is not in XML format.

nmrao
Community Hero

May be I over looked. Sorry about it.


Regards,
Rao.
jkrier
Regular Contributor

No problem, thanks for trying to help.

cancel
Showing results for 
Search instead for 
Did you mean: