1.1 JDBC API Details ResultSet
1.1.1 ResultSet: ResultSet.
- Query results by select statement.
1.1.1.1 Result Set traversal
- Result set traversal principle
- Code implementation
// 3.4 Traversal result set:
while(rs.next()){
System.out.print(rs.getInt("id") +"");
System.out.print(rs.getString("username") +"");
System.out.print(rs.getString("password") +"");
System.out.print(rs.getString("nickname") +"");
System.out.print(rs.getInt("age"));
System.out.println();
}
Copy the code
1.1.1.2 Obtaining the Result set
Result set Gets the result set that can be used:
- getXXX(); Methods usually have an overloaded method.
- getXXX(int columnIndex);
- getXXX(String columnName);