SPRING jdbcTemplate.update java.sql.SQLException:未为参数指定值

SPRING jdbcTemplate.update java.sql.SQLException:未为参数指定值,spring,jdbc,jdbctemplate,Spring,Jdbc,Jdbctemplate,我已经解决了这个问题,但我只是想知道为什么jdbcTemplate不接受我使用jdbcTemplate.update的查询,而是使用jdbcTemplate.execute,下面是带有坐标的示例代码: String query = "UPDATE geodomaindocument SET latitude=? , longitude=? WHERE url=?"; Object[] values = new Object[]{0,0,"http://example.com"} jdbcTem

我已经解决了这个问题,但我只是想知道为什么jdbcTemplate不接受我使用jdbcTemplate.update的查询,而是使用jdbcTemplate.execute,下面是带有坐标的示例代码:

String query = "UPDATE geodomaindocument SET latitude=? , longitude=?  WHERE url=?";
Object[] values = new Object[]{0,0,"http://example.com"}
jdbcTemplate.update(query, values);
返回此异常:

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE geodomaindocument SET latitude=? , longitude=?  WHERE url=?]; nested exception is java.sql.SQLException: No value specified for parameter 2
但使用相同的查询,但使用execute:

 query = "UPDATE geodomaindocument SET latitude='"+values[0]+"', longitude='"+values[1]+"' WHERE url='http://example.com'";
jdbcTemplate.execute(query);
如需任何帮助,请提前通知我

更新
好吧,我只是愚蠢,这只是一个简单的索引错误。

你的纬度和经度是字符串类型。试试这个

Object[] values = new Object[]{"0","0","http://example.com"}

不,这不是问题所在,否则spring将使用字符串[]而不是对象[]来插入变量的值。我这里也有同样的问题,您能详细解释一下如何解决这个问题吗?非常感谢~已经有一段时间了,如果我没记错的话,问题是数组索引值[i]为null或为空