java.sql.SQLException: Column Index out of range, n + 1 > n

mac2022-06-30  20

自己在跟着视频做Demo , 遇到的问题 首先找到了强大的度娘,结果发现度娘上的答案几乎千篇一律,还好安了个插件 可以访问Google,果然第一个命中我的问题,贴出来膜拜!

  首先强调的是:由于rs.next()遍历查询结果时,下标是从“1”开始,而不是是从“0”开始,此处容易导致出错。而我已避免

while(rs.next()){ int id=rs.getInt(1); String username = rs.getString(2); String password2 = rs.getString(3); Float balance = rs.getFloat(4); }

  SQL语句:

String sql = "select id , username , password , balance from users";

  正解:

 

 技术上的问题 第一时间还是Google吧!

转载于:https://www.cnblogs.com/liupengjuan/p/11603614.html

最新回复(0)