if (argNumber - 1 != expectedParams) {
throw new SQLException("Number of parameters mismatch. Expected: " + expectedParams + ", was: " + (argNumber - 1));
}
// use argument setter as it deals with various JDBC drivers setObject vs setLong/setInteger/setString etc.
ArgumentPreparedStatementSetter setter = new ArgumentPreparedStatementSetter(args);
setter.setValues(ps);
}