Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » UltraLiteJ » UltraLiteJ 参考 » UltraLiteJ API 参考

 

ResultSet 接口

提供多种方法,用于按行遍历表并访问列数据。

语法
public ResultSet
基类
注释

可以通过使用 execute 或 executeQuery 方法执行带有 SQL SELECT 语句的 PreparedStatement 生成 ResultSet。

以下示例演示了如何执行新 PreparedStatement、通过 ResultSet 读取行,以及如何访问指定列中的数据。

// Define a new SQL SELECT statement.
String sql_string = "SELECT column1, column2 FROM SampleTable";

// Create a new PreparedStatement from an existing connection.
PreparedStatement ps = conn.prepareStatement(sql_string);

// Create a new ResultSet to contain the query results of the SQL statement.
ResultSet rs = ps.executeQuery();

// Check if the PreparedStatement contains a ResultSet.
if (ps.hasResultSet()) {
    // Retrieve the column values from the first row using getString.
    while (rs.next()) {
        c1 = rs.getString(1);
        c2 = rs.getString(2);
        ...
    }
}
成员

ResultSet 的所有成员,包括所有继承的成员。


close 方法
getResultSetMetadata 方法
next 方法
previous 方法