“PreparedStatementCallback; bad SQL grammar”怎么解决?
I have an update method to update the content of a table based on a specific field and I am getting following exception.
解决方法:
Code is :
public void updateTaxoActive(String oldDesc, String description) {
Logger.getLogger(TypeCategoryJDBCTemplate.class.getName()).log(Level.INFO, "old taxonomy code is {0} new description is {1}", new Object[]{oldDesc, description}); String sql = "update product.typecategory set taxonomydescription = ? where taxonomydescription = ?";
jdbcTemplateObject.update(sql, new Object[]{description,oldDesc},new TypeCategoryMapper());
g.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select top ? * from (select top ? song.singer_id,song.song_id,song.song_name,song.title_url,song.mv_url,singer.
singer_name from webdb_prod_song as song,webdb_prod_singer as singer where song.singer_id=singer.singer_id) as music where music.singer_id not in (select top ? song.singer_id from webdb_prod_song as song,webdb_prod_singer as singer where song.
singer_id=singer.singer_id)]; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: '@P0'
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.
springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76).