首页上一页 1 下一页尾页 1 条记录 1/1页
查询所有帖子的sql报错了,网上搜索的原因都不是。
发表在JavaWeb图书答疑
2020-04-05
《JavaWeb项目开发实战入门》第3章 BBS——程序源论坛
是否精华
是
否
版块置顶:
是
否
HTTP Status 500 – Internal Server Error
Type 异常报告
消息 Request processing failed; nested exception is org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT main.*,info.info_id,info.info_reply,info.info_see,info.info_lastuser,info.info_lastime FROM my_main as main left join my_info as info on main.main_id = info.main_id ]; Parameter index out of range (1 > number of parameters, which is 0).; nested exception is java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
网上说原因是sql中“?”的数量和提供的参数数量不一致。
代码应该没问题:
//从数据库查询帖子数据 public List<Map<String, Object> > getMainPage(int row,int offset){ //分页查找my_main左连接(left join)my_info约定好每页最多显示40条帖子 String sql_select_mymain = "SELECT main.*,info.info_id,info.info_reply,info.info_see," + "info.info_lastuser,info.info_lastime FROM mrbbs.my_main as main " + "left join my_info as info on main.main_id = info.main_id " + "order by main.main_commend,main.main_creatime desc limit ?,?"; return jdbc.queryForList(sql_select_mymain,row,offset); }