DataSource.groovy 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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://localhost: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. dbProperties = this.loadProperties("classpath:mysql-connection.properties")
  30. }
  31. }
  32. hibernate {
  33. // Purposely turning off query cache
  34. cache.use_second_level_cache = false
  35. cache.use_query_cache = false
  36. cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
  37. default_batch_fetch_size=256
  38. jdbc.fetch_size=256
  39. jdbc.batch_size=500
  40. }
  41. static Properties loadProperties(String path) {
  42. PropertiesFactoryBean pfb=new PropertiesFactoryBean()
  43. pfb.setIgnoreResourceNotFound(true)
  44. def converter=new ResourceArrayPropertyEditor()
  45. converter.setAsText(path)
  46. pfb.setLocations(converter.getValue())
  47. pfb.afterPropertiesSet()
  48. return pfb.object
  49. }