为了账号安全,请及时绑定邮箱和手机立即绑定

为什么返回 org.h2.jdbc.JdbcSQLException?

为什么返回 org.h2.jdbc.JdbcSQLException?

跃然一笑 2022-09-07 17:56:18
我想设置一个计数器来从数据库中获取记录数:String sql = " select count(*) as counter from CLIENT ";conn = DBConnector.getConnection();try {    state = conn.prepareStatement(sql);    result = state.executeQuery();    Counter=result.getInt("counter");    txtUser.setText("user"+(Integer.toString(Counter)));}catch (SQLException e1) {    // TODO Auto-generated catch block    e1.printStackTrace();}为什么此代码会抛出一个 ?org.h2.jdbc.JdbcSQLException
查看完整描述

1 回答

?
手掌心

TA贡献1942条经验 获得超3个赞

result = state.executeQuery();

您还需要致电

result.next();

以前进当前行指针。

如果返回 ,则没有可用的行。result.next();false


查看完整回答
反对 回复 2022-09-07
  • 1 回答
  • 0 关注
  • 90 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号