Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Friday, July 16, 2004

Just wanted to share this example of Groovy code, which creates a text file from an Oracle table.
 import groovy.sql.Sql


x = Sql.newInstance("jdbc:oracle:thin:@x:1521:x", "x", "x", "oracle.jdbc.driver.OracleDriver")
try {
new File("sql.txt").withWriter() { writer |
x.eachRow('select * from veg_label') { row |
finally {
Groovy is a scripting language that runs on top of Java (i.e. you can access Log4J, JUnit, or any other jar). The great thing about Groovy is its brevity -- compare to what you would need to do in regular verbose Java.

More info on the coolness of Groovy:


Post a Comment

<< Home