【发布时间】:2014-04-11 06:53:51
【问题描述】:
我想使用 jdbcTemplate 将一个字符串数组传递给一个存储过程,但在这样做时遇到了麻烦。这是查询:
"SELECT * from stored_procedure(?::text[])"
这就是我使用 jdbcTemplate 调用存储过程的方式(其中 notes 是一个列表):
jdbcTemplate.queryForObject(sql, Long.class, notes == null ? null : notes.toArray());
这是我得到的错误:
PreparedStatementCallback; bad SQL grammar [SELECT * from stored_procedure(?::text[])]; nested exception is org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of [Ljava.lang.Object;. Use setObject() with an explicit Types value to specify the type to use.
我没有在网上找到任何解决此问题的方法。
【问题讨论】:
-
我不认识那个符号。你用的是什么数据库?
-
我在下面的链接stackoverflow.com/a/39357138/2147560中回答了同样的问题
标签: java arrays spring parameter-passing jdbctemplate