GROOVY Questions and Answers

Explain how you can query in Groovy?

Let see a simple example of how Groovy calls out the query

import groovy.sql.sql

sql = Sql.newInstance (‘jdbc: jtds: sqlserver://serverName/dbName-Class;domain=domainName’,’username’,’password’,’net.sourceforge.jtds.jdbc.driver’)

sql.eachRow (‘select * from tableName’) {print “$it.id–${it.firstName} –“  }