title: Using groovy.sql.Sql.executeInsert() within a Java program
body: <p><strong>EDIT</strong> Changing the question due to new information</p>
  
  <p>I'm using the Groovy SQL library in a Java program and having trouble when inserting rows in an Oracle database with the executeInsert() function. </p>
  
  <p>This is a fragment of my Java program:</p>
  
  <pre><code>    DataSet myds = registry.lookupByNameAndType("myDataSet", DataSet.class);
  
  // Use a stored function to add a row to the database and provide a keyword reference
      int[] updateCounts = myds.withBatch(100,  new Closure&lt;Object&gt;(this) {
          public Object doCall(DataSet ds) {
              Integer dupCount = 0;
              String sqlString = 
                  "INSERT INTO MY_TABLE " +
                  "(A_NUMBER_COLUMN) " +
                  "VALUES " +
                  "(':input_number')"; // one of the record Map elements
              List&lt;Object&gt; params = new ArrayList&lt;Object&gt;();
              List&lt;String&gt; keyColumnNames = new ArrayList&lt;String&gt;();
              keyColumnNames.add("MY_ID_COLUMN");
  
              for (Map&lt;String, Object&gt;record : incoming) {
                  try {
                      List&lt;GroovyRowResult&gt; keys = ds.executeInsert(record, sqlString, keyColumnNames);
                  } catch (SQLException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                      dupCount++;
                  } catch (Exception e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }
              return dupCount;
          };
      });
  </code></pre>
  
  <p>But, when the program executes, I get a SQL error that says:</p>
  
  <blockquote>
    <p>Failed to execute: INSERT INTO MY_TABLE (A_NUMBER_COLUMN) VALUES (':input_number') because: Invalid column index</p>
  </blockquote>
  
  <p>I've even tried replacing the named parameter ":input_number" with a question mark and with a constant number and got the same invalid column index error for each. It looks like the parameter substitution in the Groovy function is completely broken when used within a Java program.</p>
  
  <p>Can anyone tell me how this is supposed to work? (And, no. I don't have the option of going to a straight Groovy program.)</p>
  
  <p>Using groovy-all-2.4.11.jar and jdk.1.8.0_131</p>
  
  <p>Thanks!</p>