Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package vv.groovy.jdbc
  2.  
  3. import groovy.sql.Sql;
  4. /**
  5. * Created by vasudvis on 4/25/2017.
  6. */
  7. class Connection {
  8. public static void main(String[] args) {
  9. println 'sample'
  10. checkConnection();
  11. }
  12.  
  13. static def checkConnection(){
  14. def dbUrl = 'jdbc:postgresql://localhost/postgres'
  15. def userName = 'postgres'
  16. def password = 'password'
  17. def dbDriver = "org.postgresql.Driver"
  18.  
  19. def sql = Sql.newInstance(dbUrl, userName, password, dbDriver)
  20. sql.query('SELECT * FROM "DEMARC"."BUNIT"') {
  21. resultSet -> while(resultSet.next()){
  22. println resultSet.getString(2)
  23. }
  24. }
  25.  
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement