I know that the question has been asked for a long time, but, nevertheless, I feel that the answer can help someone there.
def personlist = [] sql = Sql.newInstance(url, username, password, driver) query = "select $reqdColName from users where id='active'" sql.eachRow(query) { row-> personlist << row.toString() } sql.close() personlist.each{println it} // you can also return the list
source share