jdbc - SPRING jdbcTemplate.update java.sql.SQLException: No value specified for parameter -


i'have solved problem wondered why jdbctemplate not accept query jdbctemplate.update work jdbctemplate.execute, here code example coordinates:

string query = "update geodomaindocument set latitude=? , longitude=?  url=?"; object[] values = new object[]{0,0,"http://example.com"} jdbctemplate.update(query, values); 

return exception:

org.springframework.jdbc.badsqlgrammarexception: preparedstatementcallback; bad sql grammar [update geodomaindocument set latitude=? , longitude=?  url=?]; nested exception java.sql.sqlexception: no value specified parameter 2 

but worked same query execute:

 query = "update geodomaindocument set latitude='"+values[0]+"', longitude='"+values[1]+"' url='http://example.com'"; jdbctemplate.execute(query); 

ty in advance help.

update ok,i'm stupid, it's simple index error.

your latitude , longitude of type string. try this

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

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -