Spring NamedParameterJdbcTemplate +一个Integers + Sybase数组

时间:2010-08-04 11:53:37

标签: spring sybase

Sooo ..我们发现了一个错误,堆栈看起来很像这个

com.sybase.jdbc2.jdbc.SybSQLException: Class [java.lang.Integer not found. Check and make sure that the class has been installed, and an entry exists in Sysxtypes.

然后我想,aaaaw,我只需将它们转换为原语。

int[] ids = ArrayUtils.toPrimitive(set.toArray(new Integer[set.size()]));

然后将ID插入查询

return namedParameterJdbcTemplate.query("select distinct id from Coffee where id in ( :ids )", Collections.singletonMap("ids", ids),
            new ParameterizedRowMapper<Integer>(){
            public Integer mapRow(ResultSet rs, int rowNum) throws SQLException {
                return rs.getInt("id");
            }
        });

确定。然后我得到了这个;

com.sybase.jdbc2.jdbc.SybSQLException: Class [I not found. Check and make sure that the class has been installed, and an entry exists in Sysxtypes.

当我将spring jdbc模板与sybase一起使用时,我从未遇到使用Integer和int的任何问题。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

而不是转换为基元,您需要将其设为List而不是数组

而不是

  

int [] ids =   ArrayUtils.toPrimitive(set.toArray(新   整数[set.size()]));

你需要做

  

Arrays.asList(IDS)