Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.82 KB | None | 0 0
  1. def dbName = 'icpar'
  2.  
  3. def db = [url     : "jdbc:mysql://localhost:3306/$dbName?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull",
  4.           user    : 'root',
  5.           password: 'pass',
  6.           driver  : 'com.mysql.jdbc.Driver']
  7.  
  8. Sql sql = Sql.newInstance(
  9.         db.url,
  10.         db.user,
  11.         db.password,
  12.         db.driver)
  13.  
  14. def attachements = sql.rows("SELECT p.payment_attachment FROM paymment p LIMIT 10,15")
  15. withPool {
  16.     attachements.each {
  17.         println(it.payment_attachment)
  18.         String url = it.payment_attachment
  19.         def f = new File("E:\\PROJECTS\\Exporter\\src\\main\\groovy\\com\\omnitech\\fileParser\\downloaded\\${url.substring(url.lastIndexOf('/') + 1)}")
  20.         new URL(url).withInputStream { i -> f.withOutputStream { it << i } }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement