stored procedures - Groovy SQL and Array parameter -
i have stored procedure accepts parameter of type array , i'd invoke via groovy.sql.sql.call(...) can't figure out how instantiate java.sql.array instance pass parameter.
in normal jdbc, can create java.sql.array via java.sql.connection.createarrayof(...) can't reference connection through groovy.sql.sql.
note, have created sql instance passing datasource groovy.sql.sql.getconnection() returns null.
the groovy.sql.sql class create connection on demand datasource , throw away when it's done. use cacheconnection keep connection around use:
def sql = new sql(datasource) sql.cacheconnection { assert sql.connection != null println sql.rows('select * mytable arraycol = ?', sql.connection.createarrayof('integer', [1, 2, 3] object[])) }
Comments
Post a Comment