Aiden Zhao Aiden Zhao - 1 year ago 96
Groovy Question

Should I close the groovy Sql in Grails service

I'm using groovy Sql in a Grails project.

class MyService{
def sessionFactory
def method(){
def sql = new Sql(sessionFactory.currentSession.connection())
def query =...

I see a lot of examples online about groovy sql in grails. All of them are not including the
in their code.

I'm wondering why. Is it because Grails has already managed the session connection after a service method is executed?
If so can you give me some evidence(or resources) I can refer to?

Answer Source

This is not necessary. Please refer to Does groovy.sql.Sql.firstRow Closes Connection After Execution?

Take a look at the link provided in the comments of the question by dmahapatro

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download