昨天遇到一个错误,之前也遇到过,但是之前遇到很快就解决了,昨天遇到这个错误当时看了大概10来分钟,还是没搞好,今天才来搞好了。

错误信息如下

  1. 08:34:43,302 DEBUG getTeachers:139 - ==> Preparing: SELECT a.*,b.classId,b.className FROM TeacherInfo a INNER JOIN ClassInfo b ON a.teacherId=b.teacherId
  2. 08:34:43,316 DEBUG NewPooledConnection:430 - com.mchange.v2.c3p0.impl.NewPooledConnection@2f187f handling a throwable.
  3. java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
  4. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
  5. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
  6. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
  7. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:862)
  8. at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3319)
  9. at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3304)
  10. at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3341)
  11. at com.mysql.jdbc.PreparedStatement.setNull(PreparedStatement.java:3380)
  12. at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setNull(NewProxyPreparedStatement.java:157)
  13. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  14. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  15. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  16. at java.lang.reflect.Method.invoke(Unknown Source)
  17. at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:70)
  18. at com.sun.proxy.$Proxy34.setNull(Unknown Source)
  19. at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:43)
  20. at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)
  21. at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)
  22. at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)
  23. at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)
  24. at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
  25. at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
  26. at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
  27. at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
  28. at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
  29. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
  30. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
  31. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  32. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  33. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  34. at java.lang.reflect.Method.invoke(Unknown Source)
  35. at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
  36. at com.sun.proxy.$Proxy15.selectList(Unknown Source)
  37. at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
  38. at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
  39. at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
  40. at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
  41. at com.sun.proxy.$Proxy20.getTeachers(Unknown Source)
  42. at com.taohan.online.exam.service.impl.TeacherInfoServiceImpl.getTeachers(TeacherInfoServiceImpl.java:59)
  43. at com.taohan.online.exam.handler.ClassInfoHandler.preUpdateClass(ClassInfoHandler.java:176)
  44. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  45. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  46. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  47. at java.lang.reflect.Method.invoke(Unknown Source)
  48. at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
  49. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
  50. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
  51. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
  52. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
  53. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
  54. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
  55. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  56. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
  57. at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
  58. at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
  59. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
  60. at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  61. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  62. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  63. at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  64. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  65. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  66. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  67. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
  68. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  69. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  70. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  71. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  72. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  73. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  74. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  75. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  76. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
  77. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
  78. at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
  79. at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  80. at java.lang.Thread.run(Unknown Source)
  81. 08:34:43,319 DEBUG SqlUtils:85 - Attempted to convert SQLException to SQLException. Leaving it alone. [SQLState: S1009; errorCode: 0]
  82. java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
  83. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
  84. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
  85. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
  86. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:862)
  87. at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3319)
  88. at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3304)
  89. at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3341)
  90. at com.mysql.jdbc.PreparedStatement.setNull(PreparedStatement.java:3380)
  91. at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setNull(NewProxyPreparedStatement.java:157)
  92. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  93. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  94. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  95. at java.lang.reflect.Method.invoke(Unknown Source)
  96. at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:70)
  97. at com.sun.proxy.$Proxy34.setNull(Unknown Source)
  98. at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:43)
  99. at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)
  100. at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)
  101. at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)
  102. at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)
  103. at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
  104. at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
  105. at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
  106. at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
  107. at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
  108. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
  109. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
  110. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  111. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  112. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  113. at java.lang.reflect.Method.invoke(Unknown Source)
  114. at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
  115. at com.sun.proxy.$Proxy15.selectList(Unknown Source)
  116. at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
  117. at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
  118. at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
  119. at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
  120. at com.sun.proxy.$Proxy20.getTeachers(Unknown Source)
  121. at com.taohan.online.exam.service.impl.TeacherInfoServiceImpl.getTeachers(TeacherInfoServiceImpl.java:59)
  122. at com.taohan.online.exam.handler.ClassInfoHandler.preUpdateClass(ClassInfoHandler.java:176)
  123. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  124. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  125. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  126. at java.lang.reflect.Method.invoke(Unknown Source)
  127. at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
  128. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
  129. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
  130. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
  131. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
  132. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
  133. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
  134. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  135. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
  136. at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
  137. at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
  138. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
  139. at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  140. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  141. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  142. at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  143. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  144. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  145. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  146. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
  147. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  148. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  149. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  150. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  151. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  152. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  153. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  154. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  155. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
  156. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
  157. at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
  158. at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  159. at java.lang.Thread.run(Unknown Source)
  160. 08:34:43,320 DEBUG DefaultConnectionTester:126 - Testing a Connection in response to an Exception:
  161. java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
  162. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
  163. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
  164. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
  165. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:862)
  166. at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3319)
  167. at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3304)
  168. at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3341)
  169. at com.mysql.jdbc.PreparedStatement.setNull(PreparedStatement.java:3380)
  170. at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setNull(NewProxyPreparedStatement.java:157)
  171. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  172. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  173. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  174. at java.lang.reflect.Method.invoke(Unknown Source)
  175. at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:70)
  176. at com.sun.proxy.$Proxy34.setNull(Unknown Source)
  177. at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:43)
  178. at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)
  179. at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)
  180. at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)
  181. at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)
  182. at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
  183. at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
  184. at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
  185. at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
  186. at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
  187. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
  188. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
  189. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  190. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  191. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  192. at java.lang.reflect.Method.invoke(Unknown Source)
  193. at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
  194. at com.sun.proxy.$Proxy15.selectList(Unknown Source)
  195. at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
  196. at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
  197. at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
  198. at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
  199. at com.sun.proxy.$Proxy20.getTeachers(Unknown Source)
  200. at com.taohan.online.exam.service.impl.TeacherInfoServiceImpl.getTeachers(TeacherInfoServiceImpl.java:59)
  201. at com.taohan.online.exam.handler.ClassInfoHandler.preUpdateClass(ClassInfoHandler.java:176)
  202. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  203. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  204. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  205. at java.lang.reflect.Method.invoke(Unknown Source)
  206. at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
  207. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
  208. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
  209. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
  210. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
  211. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
  212. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
  213. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  214. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
  215. at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
  216. at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
  217. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
  218. at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  219. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  220. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  221. at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  222. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  223. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  224. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  225. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
  226. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  227. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  228. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  229. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  230. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  231. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  232. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  233. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  234. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
  235. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
  236. at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
  237. at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  238. at java.lang.Thread.run(Unknown Source)

错误描述

错误信息关键描述

  1. Parameter index out of range (1 > number of parameters, which is 0)

  反正就是说我的参数存在问题

业务代码描述

  修改班级信息时可以修改班级对应班主任,所以需要查询出对应的非班主任教师。

  Handler

  1. @RequestMapping(value="edit/class/{classId}", method=RequestMethod.GET)
  2. public ModelAndView preUpdateClass(@PathVariable("classId") Integer classId) {
  3. logger.info("预修改班级处理");
  4.  
  5. ModelAndView model = new ModelAndView();
  6. //获取要修改班级
  7. ClassInfo classInfo = classInfoService.getClassById(classId);
  8. model.setViewName("/admin/classedit");
  9. model.addObject("editClass", classInfo);
  10. List<GradeInfo> grades = gradeInfoService.getGrades();
  11. //获取不是班主任的教师
  12. teacher.setIsWork(0); // isWork为0就不是班主任
  13. List<TeacherInfo> teachers = teacherInfoService.getTeachers(null); //通过下面配置文件可知,该方法需要传入一个 Map 集合,而我这里传入一个 null
  14. //如果没有可用班主任
  15. if (teachers.size() == 0 || teachers == null) {
  16. teacher.setTeacherId(classInfo.getTeacher().getTeacherId());
  17. teacher.setTeacherName("暂无剩余教师");
  18. teachers.add(teacher);
  19. }
  20. model.addObject("teachers", teachers);
  21. model.addObject("grades", grades);
  22.  
  23. return model;
  24. }

  映射文件

    Statement会接收一个 Map 集合

  1. <resultMap type="com.taohan.online.exam.po.TeacherInfo" id="getTeacherResultMap">
  2. <id column="teacherId" property="teacherId"/>
  3. <result column="teacherName" property="teacherName" />
  4. <result column="teacherAccount" property="teacherAccount"/>
  5. <result column="teacherPwd" property="teacherPwd"/>
  6. <result column="adminPower" property="adminPower"/>
  7. <result column="isWork" property="isWork"/>
  8. <association property="classInfo" javaType="com.taohan.online.exam.po.ClassInfo">
  9. <id column="classId" property="classId"/>
  10. <result column="className" property="className"/>
  11. </association>
  12. </resultMap>
  13.  
  14. <parameterMap type="java.util.Map" id="getTeachersParameterMap">
  15. <!-- 教师对象 -->
  16. <parameter property="teacher" resultMap="getTeacherResultMap"/>
  17. <!-- 起始位置索引 -->
  18. <parameter property="startIndex" resultMap="getTeacherResultMap"/>
  19. <!-- 每页显示数据量 -->
  20. <parameter property="pageShow" resultMap="getTeacherResultMap"/>
  21. </parameterMap>
  22.  
  23. <!-- 使用 paramenterMap 查询 -->
  24. <select id="getTeachers" parameterMap="getTeachersParameterMap" resultMap="getTeacherResultMap">
  25. SELECT a.*,b.classId,b.className FROM TeacherInfo a
  26. INNER JOIN ClassInfo b ON a.teacherId=b.teacherId
         <!--
          getTeachers()方法我传入的是 null,那么,在下面进行条件判断的时候并不能找到 teacher、startIndex、pageShow,所以抛出异常
          -->
  27. <where>
  28. <if test="teacher != null">
  29. isWork=#{teacher.isWork}
  30. </if>
  31. </where>
  32. <if test="startIndex != null and pageShow != null">
  33. LIMIT #{startIndex}, #{pageShow}
  34. </if>
  35. </select>

总结

  通过之前犯过类似的错误,以及这次错误,我发现 今后只要是 Parameter index out of range (1 > number of parameters, which is 0) 类似的错误大致定位在 映射文件调用方法传入参数

  映射文件

    如果使用了 parameterMap, resultMap,或是返回集合,就要检查参数名称和属性名称是否一致

  调用方法

    针对使用了 parameterMap 或 parameterType,需要检查传入Map中的键是否存在、匹配,或传入对象是否存在指定属性

Mabatis错误--Parameter index out of range的更多相关文章

  1. Parameter index out of range (2 > number of parameters, which is 1)

    今天在实现一个功能时遇到一个问题,解决了很久.结果是#{}与${}使用错误的原因.但是具体原因还不是很清楚,写此篇总结,知道的可以交流. 具体描述为:通过教师的头衔(1高级讲师2首席讲师)及名称进行模 ...

  2. Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0

    1.错误描述 [ERROR:]2015-05-05 16:35:50,664 [异常拦截] org.hibernate.exception.GenericJDBCException: error ex ...

  3. mybatis中Parameter index out of range (1 > number of parameters, which is 0).

    Parameter index out of range (1 > number of parameters, which is 0).(参数索引超出范围) 在mybatis里面写就是应该是 l ...

  4. java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2).

    java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2). java. ...

  5. [转]操作MySQL数据库报出:Parameter index out of range (1 > number of parameters, which is

    原文地址:https://blog.csdn.net/zdx_y/article/details/52072914 对MySQL进行insert操作,控制台抛出以下错误:Parameter index ...

  6. Parameter index out of range (1 > number of parameters, which is 0).

    数据库错误:Parameter   index   out   of   range   (1   >   number   of   parameters,   which   is   0) ...

  7. Parameter index out of range(1 > number of parameters, which is 0)参数索引超出范围

    今天在写项目的过程中,有一个模块是做多选删除操作,通过servlet获得多选框的value组,然后执行sql操作.如下: 1 @RequestMapping( "/delteCouse.do ...

  8. java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

    java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0). at co ...

  9. IDEA_MyBatis_SQLException:Parameter index out of range坑

    报错信息:超出数据库数据表设定的规定长度了 nested exception is org.apache.ibatis.type.TypeException: Could not set parame ...

随机推荐

  1. python tkinter窗口置顶

    下面两句即可实现root窗口的置顶显示,可以用于某些程序的消息提示,能够弹出到桌面显示 root = Tk()root.wm_attributes('-topmost',1)

  2. JavaScript01天学习笔记分享

    01知识点 JavaScript 代码运行在浏览器(后缀名.js) 和java完全不同的东西,只是名称类型而已 src 引用脚本   <Script></Script> ale ...

  3. CSS动画持续汇总中

    一:向上的动态箭头------------------http://www.5599.com/88lz/up_direct.html

  4. Install-Package : “XXXX”已拥有为“XXXX”定义的依赖项。

    Install-Package : “AutoMapper”已拥有为“NETStandard.Library”定义的依赖项.所在位置 行:1 字符: 16+ Install-Package <& ...

  5. 17 C#中的循环执行 while循环

    在编程中有代码的执行主要有三种方式.(1)顺序执行,也就是一条语句一条语句按顺序执行:(2)条件执行,也就是if...else.当某种条件满足时执行一些代码:(3)循环执行,就是当某种条件满足的时候, ...

  6. Hadoop的数据采集框架

    问题导读: Hadoop数据采集框架都有哪些? Hadoop数据采集框架异同及适用场景? Hadoop提供了一个高度容错的分布式存储系统,帮助我们实现集中式的数据分析和数据共享.在日常应用中我们比如要 ...

  7. [ 东莞市选 2008 ] GCD&LCM

    \(\\\) \(Description\) 给出两数的\(GCD\)和\(LCM\),求合法的两数之差的绝对值最小是多少. \(GCD\times LCM\le10^{18}\) \(\\\) \( ...

  8. 如何取消android studio启动时自动打开上次关闭的项目

    Androidstudio默认每次android studio启动就会自动打开上次关闭的项目,如果想要取消并让它显示此界面 只需要  

  9. MySql 1248 - Every derived table must have its own alias

    执行一个sql语句,报错:1248 - Every derived table must have its own alias 提示说每一个衍生出来的表,必须要有自己的别名 执行子查询的时候,外层查询 ...

  10. POJ_1847_Tram

    Tram Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 11159   Accepted: 4089 Description ...