Wednesday, April 3, 2013

Connect from to Oracle DB from Groovy

http://www.javaworld.com/community/node/2886

For Ubuntu 12.04:

groovy -cp /u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar toOracle.groovy

content of toOracle.groovy:

import groovy.sql.Sql

sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:xe", "user_schema", "password",
"oracle.jdbc.pool.OracleDataSource")
sql.eachRow("SELECT id FROM user_schema.table_name")
{
println "The employee's name is ${it.id}."
}

No comments:

Post a Comment