org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 2

Spring JIRA | Seth Weiner | 6 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    the JdbcSearchableJobExecutionDao.getJobExecutions uses the SimpleJdbcTemplate queryForLong method and passes the query generated by an instance of PagingQueryProvider's generateJumpToItemQuery method. This is problematic when using the OraclePagingQueryProvider because generateJumpToItemQuery returns a resultset with two columns due to the use of Oracle's ROWNUM feature. As a result, the SingleColumnRowMapper that the SimpleJdbcTemplate uses to extract the Long blows up. The JdbcSearchableJobExecutionDao.getJobExecutions (and other paging methods) probably needs to be tweaked to stop using queryForLong and just use the first column retrieved. Alternatively, the OraclePagingQueryProvider.generateJumpToItemQuery could be mangled a bit to only return 1 column. The referenced spring forum post runs into this issue in the second to last entry, but it doesn't identify this as the root cause. Here's the stack trace: {noformat} 2010-10-07 13:39:17,016 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[Batch Servlet]] - Servlet.service() for servlet Batch Servlet threw exception org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 2 at org.springframework.jdbc.core.SingleColumnRowMapper.mapRow(SingleColumnRowMapper.java:87) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:1) at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:445) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:395) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:455) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:463) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:471) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:476) at org.springframework.jdbc.core.JdbcTemplate.queryForLong(JdbcTemplate.java:480) at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForLong(SimpleJdbcTemplate.java:127) at org.springframework.batch.admin.service.JdbcSearchableJobExecutionDao.getJobExecutions(JdbcSearchableJobExecutionDao.java:190) at org.springframework.batch.admin.service.SimpleJobService.listJobExecutions(SimpleJobService.java:220) at org.springframework.batch.admin.web.JobExecutionController.list(JobExecutionController.java:156) ...snip... {noformat}

    Spring JIRA | 6 years ago | Seth Weiner
    org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 2
  2. 0

    the JdbcSearchableJobExecutionDao.getJobExecutions uses the SimpleJdbcTemplate queryForLong method and passes the query generated by an instance of PagingQueryProvider's generateJumpToItemQuery method. This is problematic when using the OraclePagingQueryProvider because generateJumpToItemQuery returns a resultset with two columns due to the use of Oracle's ROWNUM feature. As a result, the SingleColumnRowMapper that the SimpleJdbcTemplate uses to extract the Long blows up. The JdbcSearchableJobExecutionDao.getJobExecutions (and other paging methods) probably needs to be tweaked to stop using queryForLong and just use the first column retrieved. Alternatively, the OraclePagingQueryProvider.generateJumpToItemQuery could be mangled a bit to only return 1 column. The referenced spring forum post runs into this issue in the second to last entry, but it doesn't identify this as the root cause. Here's the stack trace: {noformat} 2010-10-07 13:39:17,016 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[Batch Servlet]] - Servlet.service() for servlet Batch Servlet threw exception org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 2 at org.springframework.jdbc.core.SingleColumnRowMapper.mapRow(SingleColumnRowMapper.java:87) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:1) at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:445) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:395) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:455) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:463) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:471) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:476) at org.springframework.jdbc.core.JdbcTemplate.queryForLong(JdbcTemplate.java:480) at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForLong(SimpleJdbcTemplate.java:127) at org.springframework.batch.admin.service.JdbcSearchableJobExecutionDao.getJobExecutions(JdbcSearchableJobExecutionDao.java:190) at org.springframework.batch.admin.service.SimpleJobService.listJobExecutions(SimpleJobService.java:220) at org.springframework.batch.admin.web.JobExecutionController.list(JobExecutionController.java:156) ...snip... {noformat}

    Spring JIRA | 6 years ago | Seth Weiner
    org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 2

    Root Cause Analysis

    1. org.springframework.jdbc.IncorrectResultSetColumnCountException

      Incorrect column count: expected 1, actual 2

      at org.springframework.jdbc.core.SingleColumnRowMapper.mapRow()
    2. Spring Framework
      SimpleJdbcTemplate.queryForLong
      1. org.springframework.jdbc.core.SingleColumnRowMapper.mapRow(SingleColumnRowMapper.java:87)
      2. org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
      3. org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:1)
      4. org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:445)
      5. org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:395)
      6. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:455)
      7. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:463)
      8. org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:471)
      9. org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:476)
      10. org.springframework.jdbc.core.JdbcTemplate.queryForLong(JdbcTemplate.java:480)
      11. org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForLong(SimpleJdbcTemplate.java:127)
      11 frames
    3. org.springframework.batch
      JobExecutionController.list
      1. org.springframework.batch.admin.service.JdbcSearchableJobExecutionDao.getJobExecutions(JdbcSearchableJobExecutionDao.java:190)
      2. org.springframework.batch.admin.service.SimpleJobService.listJobExecutions(SimpleJobService.java:220)
      3. org.springframework.batch.admin.web.JobExecutionController.list(JobExecutionController.java:156)
      3 frames