Groovy web console

subscribe to the feed Subscribe
to this
site
sql city (via #groovywebconsole)
tweet this snippet Tweet
this
script

sql city

Published 5 months ago by mikew
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.sql.Sql  

Sql db 
try {    
   db = Sql.newInstance( 'url', 'user', 'pwd', 'yourDriver' )     
   db.eachRow( 'select * from address where address1 = ? and address2 = ?', [csv.address1, csv.address2] ) {
       if ( csv.city != it.city ) {
            // do stuff
       }
   }
} 
finally {     
   db?.close() 
}