简体   繁体   English

groovy sql withbatch的问题

[英]Problems with groovy sql withbatch

I usually wouldn't post for problems with an API but I'm completely stumped. 我通常不会发布API的问题,但我完全难过。 I'm trying to use groovy's withBatch() method and it is blowing up on me. 我正在尝试使用groovy的withBatch()方法,它正在炸毁我。 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() groovy.lang.MissingMethodException:没有方法签名:groovy.sql.Sql.withBatch()适用于参数类型:(java.lang.String,... updater.InsertAllService $ _updateData_closure1)值:[插入SCHEMA.TABLE (值,值,值,值,值,值,值,值,值,值,值,值)值(?,?,?,?,?,?,?,?,?,?,?,? ),... updater.InsertAllService$_updateData_closure1@74eb011d]可能的解决方案: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. 整个上午我一直在尝试不同的东西(包括另一个withBatch方法)并且我一直得到同样的错误。 Does anyone see what I'm doing? 有谁看到我在做什么? Thanks! 谢谢!

What version of Groovy? 什么版本的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. 采用String和Closure的withBatch变体仅在Groovy 1.8中引入,错误消息中的“可能的解决方案”表明您使用的是Groovy 1.7。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM