[groovy-user] Groovy Sql - How to get values from GroovyResultSet

505 views
Skip to first unread message

Dean Del Ponte

unread,
Jan 26, 2012, 5:51:35 PM1/26/12
to us...@groovy.codehaus.org
I have the following code:

sql.eachRow( 'select * from tableName' ) { println it.values() }

The above code doesn't work because "values()" cannot be called on a GroovyResultSet although it looks like a map.

What's the best way to get all of the values from the result set?

Thanks,

Dean Del Ponte

Dinko Srkoc

unread,
Jan 26, 2012, 6:55:11 PM1/26/12
to us...@groovy.codehaus.org

GroovyResutSet is not a map, it's a java.sql.ResultSet (well, extends
it anyway). If you want a map do this:

sql.eachRow('...') { println it.toRowResult().values() }

This way you can convert GroovyResultSet to GroovyRowResult which is a map.

Cheers,
Dinko

>
> Thanks,
>
> Dean Del Ponte

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Reply all
Reply to author
Forward
0 new messages