只有在从rs.getString 1中选择结果后才能在下一行显示rs.getString2?
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("select * from state");
while ( rs.next() ){
System.out.println(rs.getString(1) + " " +rs.getString(2));
答案 0 :(得分:0)
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("select * from state");
while ( rs.next() ){
StringBuilder br = new StringBuilder();
br.append(rs.getString(1)); //print the column 1 in the current row
br.append(" "); //add space
rs.next(); //move to the next row
br.append(rs.getString(2)); //print the column 2 in the next row
rs.previous(); //go back to the current row of this current iteration
System.out.println(br.toString()); //print
}