groovy-sql

GroovySql: How to update a table with Arraylist variables

夙愿已清 提交于 2019-12-24 08:06:37
问题 I am trying to write an GroovySQL script that will have three different Arraylist variable. A1[1,2,3],A2[4,5,6],A3[7,8,9]. I want to update the table such that three rows of the three columns of the table are updates as Data should be (in row wise) R1: 1,4,7 R2: 2,5,8 R3: 3,6,9 def sql = Sql.newInstance("jdbc:mysql://localhost:3306/words", "Test", "test", "com.mysql.jdbc.Driver") def nid = 1 def newupdate = "hello world" sql.executeUpdate("update word set spelling = ? where word_id = ?", [

How do you know when GroovyStrings are not treated the same as Strings?

泪湿孤枕 提交于 2019-12-12 18:24:27
问题 I've just run into a confusing issue in Groovy while trying to modify a MySQL database. What appears to be identical code throws an Exception unless my GroovyString is explicitly converted to a java.lang.String : import groovy.sql.Sql def sql = Sql.newInstance('jdbc:mysql://localhost/test?useUnicode=yes&characterEncoding=UTF-8', 'user', 'pass', 'com.mysql.jdbc.Driver') def tableName = 'my_table' sql.execute "truncate $tableName" throws: com.mysql.jdbc.exceptions.jdbc4

Runtime Exception Mocking groovy.sql in Spock

我的未来我决定 提交于 2019-12-11 02:19:39
问题 I've scoured around StackOverflow and Google for a while trying to find the right configuration/syntax for being able to run this code in a Spock Specification: Sql mockSql = Mock() However when I run the unit test, I get a nasty exception thrown in my face by CGLIB: java.lang.IllegalAccessError: tried to access method groovy.sql.Sql.<init>()V from class groovy.sql.Sql$$EnhancerByCGLIB$$d0b7cd7f at org.spockframework.mock.runtime.MockInstantiator.instantiate(MockInstantiator.java:33) at org