Source

grails jasypt presentation / demo-jasypt / consoleDemo.groovy

Full commit
import groovy.sql.Sql
import jasypt.demo.*

def eachRow(sql, closure = null) {
    withDb { db ->
        db.eachRow(sql) { row ->
            if (closure) return closure(row)
            println row
        }
    }
}

def withDb(closure) {
    new Sql(dataSource).with { db ->
        try { closure(db) } finally { db.close() }
    }
}

def getDataSource() { grailsApplication.mainContext.getBean("dataSource") }

def retrievePerson() {
    Person.findByLastName("Naleid") ?: 
    Person.build(lastName: "Naleid", ssn: "123456789")
}

def p = retrievePerson()  
p.ssn = "123456789"
p.save(failOnError: true, flush: true)

eachRow("select * from person"){ println it}