I have set up a user DSN ODBC datasource in WinXP (Version: Excel 97-2000) for a very simple excel spreadsheet:
A_NUMBER A_DATE A_STRING
1001 10/1/2012 Red
1002 10/2/2012 Green
1003 10/3/2012 Blue
When I run the following groovy script (Groovy Version: 1.7.8 JVM: 1.6.0_10) to read the data
import groovy.sql.Sql
def static main(def args) {
def dbParameters = [url: 'jdbc:odbc:mySpreadSheet', user:'', password:'', driver: 'sun.jdbc.odbc.JdbcOdbcDriver']
def sql = Sql.newInstance(dbParameters)
sql.eachRow('select * from [Sheet1$]') { row ->
println "${row.A_NUMBER} ${row.A_DATE} ${row.A_STRING}"
}
sql.close()
println "done???"
}
it produces the following output:
1001.0 2012-10-01 00:00:00.0 Red
1002.0 2012-10-02 00:00:00.0 Green
1003.0 2012-10-03 00:00:00.0 Blue
done???
but it never exits!
I have tried running it from a windows command prompt and a cygwin bash shell and in both cases it hangs until I kill with a ctrl-c
I can force the script to exit by adding
throw new RuntimeException("force exit")
after the println but that seems pretty extreme.
Any idea why the script is hanging?
System.exit(0)will be a little bit nicer... - rdmueller