Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package vv.groovy.jdbc
- import groovy.sql.Sql;
- /**
- * Created by vasudvis on 4/25/2017.
- */
- class Connection {
- public static void main(String[] args) {
- println 'sample'
- checkConnection();
- }
- static def checkConnection(){
- def dbUrl = 'jdbc:postgresql://localhost/postgres'
- def userName = 'postgres'
- def password = 'password'
- def dbDriver = "org.postgresql.Driver"
- def sql = Sql.newInstance(dbUrl, userName, password, dbDriver)
- sql.query('SELECT * FROM "DEMARC"."BUNIT"') {
- resultSet -> while(resultSet.next()){
- println resultSet.getString(2)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement