title: Groovy Sql.execute() with sql statement as string variable not working
body: <p>I am trying to execute a sql statement in groovy by passing the statement as a string variable rather than a string literal.  The reason I am using a string variable is because I am reading the sql statement from a file.  </p>
  
  <p>For example (assuming sql is a valid Instance of groovy.sql.Sql - which I have verified):</p>
  
  <pre><code>sql.execute("insert into table(id) values(1)")
  </code></pre>
  
  <p>Works just fine.</p>
  
  <p>However, the following does not:</p>
  
  <pre><code>def str = "insert into table(id) values(1)"
  sql.execute(str)
  </code></pre>
  
  <p>The last example just hangs when I run it.  No SQL errors, it just stalls.  I tried putting a println after the execute and it never reaches the println statement.</p>
  
  <p>So, I tried the following variations:</p>
  
  <pre><code>sql.execute("$str")
  </code></pre>
  
  <p>and </p>
  
  <pre><code>sql.execute("${str}")
  </code></pre>
  
  <p>and even</p>
  
  <pre><code>sql.execute("?", [str])
  </code></pre>
  
  <p>for curiosity's sake, but all give the following error:</p>
  
  <pre><code>Mar 21, 2013 6:28:16 PM groovy.sql.Sql execute
  WARNING: Failed to execute: ? because: Invalid SQL type: sqlKind = 0
  Caught: java.sql.SQLException: Invalid SQL type: sqlKind = 0
  java.sql.SQLException: Invalid SQL type: sqlKind = 0
          at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:77)
          at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010)
          at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
          at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
          at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3677)
          at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
          at runSqlFile.run(runSqlFile.groovy:40)
  </code></pre>
  
  <p>I am admittedly new to groovy, but I can't figure out why a string literal works but the variable will not.  Any help here would be greatly appreciated.  Let me know if more information is needed.</p>
  
  <p>Also, the reason I am grabbing individual sql statements from a file is because I could not find a way to execute an entire .sql file using groovy.  If there is a simple way to do that which I haven't found, that would also solve my problem. Thanks in advance.</p>