============问题描述============
在服务端,通过如下代码将查询结果放到list中,结果发现没有第一行。明明用beforeFirst()移动到第一行了,却还是没有效果。请问这是怎么回事?
JDBConnection sqlConn = new JDBConnection(); ResultSet resRes = sqlConn.executeQuery("select * from message"); int row = 0; try { resRes.last(); row = resRes.getRow(); ResultSetMetaData resMD = resRes.getMetaData(); int columns = resMD.getColumnCount(); listAll.clear(); resRes.beforeFirst(); System.out.println(resRes.next()); while (resRes.next()) { for (int i = 1; i <= columns; i++) { System.out.println(resRes.getString(i)); listAll.add(resRes.getString(i)); } } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }
============解决方案1============
把第一行舍掉吧
时间: 2024-10-14 05:17:10