SQL查询结果
SqlResultSet 类提供了一个列名集合作为 getColumnNames 属性,以及作为 SqlTuple 类对象的行。这些可以使用 Java 的 for 循环进行迭代,如下代码片段所示:
SqlResultSet result = con.executeQuery("select pk,value from MyTable where pk>=?", 2013);
for (String column : result.getColumnNames())
{
System.out.print(column + ", ");
}
System.out.println();
for (SqlTuple tuple : result)
{
System.out.println(tuple.getInt(0) + ", " + tuple.get("value"));
}