import org.springframework.jdbc.core.JdbcTemplate
...
jdbcTemplate(JdbcTemplate) {
dataSource = ref('dataSource')
...
}
DataSource.groovy
dataSource {
configClass = GrailsAnnotationConfiguration.class
pooled = true
autoreconnect= true
}
hibernate {
generate_statistics=true
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory'
}
environments {
development {
dataSource {
driverClassName = "com.mysql.jdbc.Driver"
username = "test"
password = "test"
dbCreate = "update" // one of 'create', 'create-drop','update'
pooled = true
jmxExport = true
url = "jdbc:mysql://host:port/dbName?autoReconnect=true"
}
}
}
Service class
def jdbcTemplate
def someMethod(){
jdbcTemplate.queryForList(somequery)
}
Exception: Cannot invoke method queryForList() on null object. Stacktrace follows: Message: Cannot invoke method queryForList() on null object
Any help is appreciated.
Thanks
Shweta
Question posted on stackoverflow -
http://stackoverflow.com/questions/39120000/grails-app-upgrade-2-5-datasource-is-null