DataSource.groovy 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import org.springframework.beans.factory.config.PropertiesFactoryBean
  2. import org.springframework.core.io.support.ResourceArrayPropertyEditor
  3. dataSource {
  4. pooled = true
  5. dbCreate = "update"
  6. url = "jdbc:mysql://TFB-database:3306/hello_world"
  7. driverClassName = "com.mysql.jdbc.Driver"
  8. dialect = org.hibernate.dialect.MySQL5InnoDBDialect
  9. username = "benchmarkdbuser"
  10. password = "benchmarkdbpass"
  11. properties {
  12. fairQueue = false
  13. maxActive = 512
  14. maxIdle = 25
  15. minIdle = 5
  16. initialSize = 5
  17. minEvictableIdleTimeMillis = 60000
  18. timeBetweenEvictionRunsMillis = 60000
  19. maxWait = 10000
  20. maxAge = 1800 * 1000
  21. numTestsPerEvictionRun=3
  22. testOnBorrow=false
  23. testWhileIdle=true
  24. testOnReturn=false
  25. validationQuery="/* ping */"
  26. validationInterval=15000
  27. jdbcInterceptors="ConnectionState;StatementCache"
  28. defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED
  29. defaultAutoCommit=true
  30. dbProperties = this.loadProperties("classpath:mysql-connection.properties")
  31. }
  32. }
  33. hibernate {
  34. // Purposely turning off query cache
  35. cache.use_second_level_cache = false
  36. cache.use_query_cache = false
  37. cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
  38. default_batch_fetch_size=256
  39. jdbc.fetch_size=256
  40. jdbc.batch_size=500
  41. }
  42. static Properties loadProperties(String path) {
  43. PropertiesFactoryBean pfb=new PropertiesFactoryBean()
  44. pfb.setIgnoreResourceNotFound(true)
  45. def converter=new ResourceArrayPropertyEditor()
  46. converter.setAsText(path)
  47. pfb.setLocations(converter.getValue())
  48. pfb.afterPropertiesSet()
  49. return pfb.object
  50. }