Reputation:
I usually wouldn't post for problems with an API but I'm completely stumped. I'm trying to use groovy's withBatch() method and it is blowing up on me. Here's what I'm trying:
connection.withBatch ('insert into SCHEMA.TABLE(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE) values (?,?,?,?,?,?,?,?,?,?,?,?)') { ps ->
for(def dom : domain.domainData)
{
def values = dom.collect {key, value -> value}
ps.addBatch(values)
}
And I keep getting this:
groovy.lang.MissingMethodException: No signature of method: groovy.sql.Sql.withBatch() is applicable for argument types: (java.lang.String, ...updater.InsertAllService$_updateData_closure1) values: [insert into SCHEMA.TABLE(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE) values (?,?,?,?,?,?,?,?,?,?,?,?), ...updater.InsertAllService$_updateData_closure1@74eb011d] Possible solutions: withBatch(groovy.lang.Closure), withBatch(int, groovy.lang.Closure), isWithinBatch()
(I had to take out the values and package names for privacy reasons)
I have been tinkering with this all morning trying different things (including the other withBatch methods) and I keep getting this same error. Does anyone see what I'm doing? Thanks!
Upvotes: 0
Views: 1184
Reputation: 122364
What version of Groovy? The withBatch
variant that takes a String and a Closure was only introduced in Groovy 1.8, the "possible solutions" in your error message suggest you're on Groovy 1.7.
Upvotes: 2