groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thom DeCarlo <>
Subject Trouble with groovy.sql
Date Wed, 03 May 2017 17:59:22 GMT
I'm using the groovy.sql libraries inside of a Java program and having
trouble with parameter substitution. My code looks like this:

Map<String, Object>params = new HashMap<String, Object>();
params.put("source_system_id", Integer.valueOf(6));
params.put("rec_loc_txt", "Test" + randomNum.toString());
params.put("created_dt_tm", jts);
String mdSqlString = "INSERT INTO MD_CATALOG " +
                 "      (SOURCE_SYSTEM_ID, REC_LOC_TXT, CREATED_DT_TM)" +
                 "      VALUES" +
                 "      (:source_system_id, :rec_loc_txt, :created_dt_tm)";

try {
List<List<Object>> keys = mdds.executeInsert(params, mdSqlString);
} catch (SQLException e) {
// TODO Auto-generated catch block

But, when it runs, I get an exception thrown that says:

Exception in thread "main" java.lang.IllegalArgumentException: Found 4
parameter placeholders but supplied with 3 parameters
at groovy.sql.Sql.setParameters(
at groovy.sql.Sql.getPreparedStatement(
at groovy.sql.Sql.executeInsert(
at groovy.sql.Sql.executeInsert(
at org.mitre.mac.Main.main(

Now, I only see 3 placeholders for my 3 parameters. Can anyone tell me
where I'm going wrong?


View raw message