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

Groovy SQL insertion failing against SQL Server using JTDS

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.0-RC-1
    • 1.1-beta-1
    • groovy-jdk
    • None
    • Linux, Fedora Core 3, Java 1.5, JTDS 1.2, SQL Server 2000

    Description

      The current Sql.executeInsert (String, LIst) which all code goes through uses this way of executing a prepared statement:

      statement = connection.prepareStatement(sql);
      setParameters(params, statement);
      configure(statement);
      boolean hasResultSet = statement.execute(sql, Statement.RETURN_GENERATED_KEYS);

      The JTDS driver complains about this - you're not meant to call execute passing in some SQL when it's already been prepared.
      The following code works instead:

      statement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
      setParameters(params, statement);
      configure(statement);
      this.updateCount = statement.executeUpdate();

      Apologies for this not being provided as a patch - I haven't looked yet to see where else it might be occurring, and I also haven't worked out the best way of unit testing it (beyond mocks). I wanted to raise it in time for someone more experienced to look before v1 goes out though!

      Attachments

        1. executeInsert.patch
          1 kB
          Simon Raess

        Activity

          People

            guillaume Guillaume Sauthier
            jskeet Jon Skeet
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: