×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Groovy
Posted by: Alejandro Aragón
Added: Aug 21, 2013 10:58 PM
Views: 18
Conexión a base de datos Oracle y consulta
  1. import oracle.jdbc.pool.OracleDataSource
  2. import groovy.sql.*
  3.  
  4. OracleDataSource ds = new OracleDataSource()
  5. ds.user = 'user'
  6. ds.password = 'pass'
  7. ds.driverType = 'thin'
  8. ds.serverName = 'host/ip'
  9. ds.portNumber = 1521
  10. ds.databaseName = 'instancia/nombreBD'
  11.  
  12. Sql sql = new Sql(ds)
  13.  
  14. sql.eachRow("SELECT * FROM tabla") { row ->
  15.     println row.COLUMNA
  16. }
  17.  
  18. sql.close()