您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

SqlServer的The result set has no current row错误处理

bubuko 2022/1/25 19:14:14 sqlserver 字数 1936 阅读 767 来源 http://www.bubuko.com/infolist-5-1.html

错误描述 Integer totalCount = jdbcTemplate.query("select count(*) as count from xxx", (rs) -> { return rs.getInt("count"); }); 错误信息 Caused by: com.microso ...

错误描述

Integer totalCount = jdbcTemplate.query("select count(*) as count from xxx", (rs) -> {
      return rs.getInt("count");
    });

错误信息

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The result set has no current row.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:228)
	at com.microsoft.sqlserver.jdbc.SQLServerResultSet.verifyResultSetHasCurrentRow(SQLServerResultSet.java:510)
	at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getterGetColumn(SQLServerResultSet.java:1883)
	at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1919)
	at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1900)
	at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getInt(SQLServerResultSet.java:2135)

原因

技术分享图片

此时游标没有指向真正的数据行。

解决

Integer totalCount = jdbcTemplate.query("select count(*) as count from xxx", (rs) -> {
      rs.next();
      return rs.getInt("count");
    });

参考

com.microsoft.sqlserver.jdbc.SQLServerException: The result set has no current row

SqlServer的The result set has no current row错误处理

原文:https://www.cnblogs.com/strongmore/p/14513908.html


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶