Skip to content

Instantly share code, notes, and snippets.

@galak-fyyar
Created July 29, 2012 20:41
Show Gist options
  • Save galak-fyyar/3201729 to your computer and use it in GitHub Desktop.
Save galak-fyyar/3201729 to your computer and use it in GitHub Desktop.
Prototyping with Groovy
[ "cat", "dog", "bird" ] as String[]
new String[] { "cat", "dog", "bird" }
unnamedCustomers = customers.findAll {
it.name == 'John Doe'
}
@Grab(group='com.caucho', module='hessian', version='[3.2.0,)')
println customers.join(',')
@GrabConfig(systemClassLoader=true)
@Grab(group='com.h2database', module='h2', version='1.3.167')
def sql = Sql.newInstance("jdbc:h2:/tmp/customers", "sa", "", "org.h2.Driver")
sql.withTransaction {
sql.execute("CREATE TABLE customer(id bigint primary key auto_increment, name varchar)")
}
def customerName = 'John Smith'
sql.eachRow "select * from customer where name = $customerName" {
println it.toRowResult()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment