I'm getting the exception shown below, when I run the following query with jdbc. This is a simplified example, the other parts of the preparedStatementSetter with setString and setInt, etc. ran successfully.
public List<EmployeeMonitoringResultTo> searchEmployeesForEmployerInRange(final GetEmployeesForEmployerInRangeCriteria criteria) {
final StringBuilder sql =
new StringBuilder( "select * from CODES c ")
.append(" where c.TYPE in ( ? ) "); // TYPE has DATA_TYPE 12, TYPE_NAME VARCHAR
return jdbcTemplate.query(
sql.toString(),
new PreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps) throws SQLException {
ps.setArray(1, searchTypes());
}
},
new SpecificRowMapper<SpecType>()
);
}
private Array searchTypes() {
final Collection<String> collection = fetchStrings();
Array resultArray = null;;
try {
resultArray = jdbcTemplate.getDataSource().getConnection().createArrayOf("VARCHAR", collection.toArray());
} catch (SQLException e) {
log.error("Problem with created java.sql.Array", e);
throw e;
}
return resultArray;
}
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10349][11717][4.13.80] Unsupported cross conversion from source type Object;. ERRORCODE=-4461, SQLSTATE=42815 at com.ibm.db2.jcc.am.id.a(id.java:677) at com.ibm.db2.jcc.am.id.a(id.java:60) at com.ibm.db2.jcc.am.id.a(id.java:103) at com.ibm.db2.jcc.am.ic.a(ic.java:289) at com.ibm.db2.jcc.am.ic.a(ic.java:191) at com.ibm.db2.jcc.am.kc.a(kc.java:1943) at com.ibm.db2.jcc.am.go.a(go.java:2289) at com.ibm.db2.jcc.am.go.setArray(go.java:2254) at com.jolbox.bonecp.PreparedStatementHandle.setArray(PreparedStatementHandle.java:261) at net.sf.log4jdbc.PreparedStatementSpy.setArray(PreparedStatementSpy.java:349) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) ... 93 more