該代碼返回除第一行之外的每一行。我看不出它有什麼問題?我如何使它包括第一個?ResultSet元數據不返回第一行
stmt = con.createStatement();
ResultSet res=stmt.executeQuery("SELECT * FROM Orders ORDER BY OrderID");
if (res.next())
{
ResultSetMetaData rsmd=res.getMetaData();
int columnCount=rsmd.getColumnCount();
for (int i = 1; i<= columnCount; i++) {
columnHeading=columnHeading+"\t"+rsmd.getColumnName(i);
}
System.out.println(columnHeading);
while(res.next()) {
for (int i= 1; i<= columnCount; i++) {
System.out.print("\t"+res.getString(i));
}
System.out.println("\n");
}
}