Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5375

Sql has newInstance methods which create connections but doesn't manage them

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0-beta-3, 1.8.7
    • None
    • None

    Description

      It would be useful to have variations of some of the groovy.sql.Sql#newInstance methods which took care of resource management, e.g. instead of this:

      def sql
      try {
        sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
        // sql operations here
      } finally {
        sql?.close()
      }
      

      You could do something like:

      Sql.withInstance(db.url, db.user, db.password, db.driver) { sql ->
        // sql operations here
      }
      

      Attachments

        Activity

          People

            paulk Paul King
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: