Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. dataSource_target {
  2. dialect = org.hibernate.dialect.MySQLInnoDBDialect
  3. pooled = true
  4. jmxExport = true
  5. driverClassName = "com.mysql.jdbc.Driver"
  6. username = "bla"
  7. password = "bla"
  8. }
  9.  
  10. static mapping = {
  11. datasource 'ALL'
  12. }
  13.  
  14. con = new Sql(dataSource_target)
  15. rows = con.rows(sql)
  16.  
  17. dataSource_target {
  18. dialect = org.hibernate.dialect.MySQLInnoDBDialect
  19. pooled = true
  20. jmxExport = true
  21. driverClassName = "com.mysql.jdbc.Driver"
  22. username = "bla"
  23. password = "bla"
  24. properties {
  25. maxActive = -1
  26. minEvictableIdleTimeMillis=1800000
  27. timeBetweenEvictionRunsMillis=1800000
  28. numTestsPerEvictionRun=3
  29. testOnBorrow=true
  30. testWhileIdle=true
  31. testOnReturn=true
  32. validationQuery="SELECT 1"
  33. }
  34. }
  35.  
  36. def db = [
  37. url:'jdbc:hsqldb:mem:testDB',
  38. user:'sa',
  39. password:'',
  40. driver:'org.hsqldb.jdbc.JDBCDriver'
  41. ]
  42. def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
  43.  
  44. def db = [:]
  45. def dataSources = Holders.grailsApplication.config.dataSources
  46. db.user = dataSources.dataSource_otherDsn.username
  47. db.password = dataSources.dataSource_otherDsn.password
  48. db.driver = dataSources.dataSource_otherDsn.driverClassName
  49. if (Environment.current == Environment.DEVELOPMENT) {
  50. db.url = Holders.grailsApplication.config.environments.development.dataSources.dataSource_otherDsn.url
  51. } else if (Environment.current == Environment.PRODUCTION) {
  52. db.url = Holders.grailsApplication.config.environments.production.dataSource.dataSource_otherDsn.url
  53.  
  54. }
  55. def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement