Guest User

Untitled

a guest
May 13th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import groovy.sql.Sql
  2.  
  3. buildscript {
  4. repositories {
  5. mavenCentral()
  6. }
  7.  
  8. dependencies {
  9. classpath 'com.microsoft.sqlserver:mssql-jdbc:6.4.0.jre8'
  10. }
  11.  
  12. configurations.classpath.each { Sql.classLoader.addURL it.toURI().toURL() }
  13. }
  14.  
  15. task somethingWithMSSQL() {
  16. def dbHost = "host"
  17. def dbPort = "1433"
  18. def dbUsername = "username"
  19. def dbPassword = "password"
  20. def dbName = "database"
  21. def dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  22.  
  23. def jdbcUrl = "jdbc:sqlserver://$dbHost:$dbPort;databaseName=$dbName"
  24. def sql = Sql.newInstance(jdbcUrl, dbUsername, dbPassword, dbDriver)
  25.  
  26. // do something with MSSQL
  27.  
  28. sql.close()
  29. }
Add Comment
Please, Sign In to add comment