groovy insert语句可以';t推断用于org.codehaus.groovy.runtime.GStringImpl实例的SQL类型

groovy insert语句可以';t推断用于org.codehaus.groovy.runtime.GStringImpl实例的SQL类型,sql,groovy,insert,Sql,Groovy,Insert,错误消息: URI /racetrack/readUserRole/index Class org.postgresql.util.PSQLException Message Can't infer the SQL type to use for an instance of org.codehaus.groovy.runtime.GStringImpl. Use setObject() with an explicit Types value to specify the type to us

错误消息:

URI
/racetrack/readUserRole/index
Class
org.postgresql.util.PSQLException
Message
Can't infer the SQL type to use for an instance of org.codehaus.groovy.runtime.GStringImpl. Use setObject() with an explicit Types value to specify the type to use
代码:


在insert语句中出现错误消息,那么我该如何解决此sql类型问题呢?

使用类上的静态方法将变量包装为数据库已知的类型。例如,要将
GString
包装为
varchar
,可以使用:

import static groovy.sql.Sql.*

....

sql.eachRow("select * from foo where name = ${VARCHAR(myVar)}")

你能显式地施法吗?e、 g.
list2=[t,i,r]*.toString()
?此外,您的选择可能会受到sql注入的攻击
import static groovy.sql.Sql.*

....

sql.eachRow("select * from foo where name = ${VARCHAR(myVar)}")