提供若干方法,用于执行 SQL 查询以生成 ResultSet,或用于对 UltraLite 数据库执行准备的 SQL 语句。
public interface PreparedStatement
PreparedStatement 接口的所有成员,包括所有继承的成员。
名称 | 说明 |
---|---|
关闭 PreparedStatement,以释放与其相关的内存资源。 | |
执行准备的 SQL 语句。 | |
执行准备的 SQL SELECT 语句并返回 ResultSet。 | |
返回 OutputStream。 | |
返回写入器。 | |
返回由名称表示的值的序数(基数:1)。 | |
返回对 SQL 查询执行计划的基于文本的说明。 | |
返回对 SQL 查询执行计划的基于文本的说明,以树形结构显示。 | |
返回准备的 SQL 语句的 ResultSet。 | |
返回自上一次执行语句之后插入、更新或删除的行数。 | |
确定 PreparedStatement 是否包含 ResultSet。 | |
将值设置为 SQL 语句中的主机变量。 | |
为 SQL 语句中由 ordinal 参数定义的主机变量设置空值。 |
以下示例演示了如何执行 PreparedStatement、检查执行过程是否创建了 ResultSet、将 ResultSet 保存到局部变量,以及如何关闭 PreparedStatement:
// Create a new PreparedStatement object from an existing connection. String sql_string = "SELECT * FROM SampleTable"; PreparedStatement ps = conn.prepareStatement(sql_string); // result returns true if the execute statement runs successfully. boolean result = ps.execute(); // Check if the PreparedStatement contains a ResultSet. if (ps.hasResultSet()) { // Store the ResultSet in the rs variable. ResultSet rs = ps.getResultSet; } // Close the PreparedStatement to release resources. ps.close(); When a statement contains expressions, it may contain a host variable wherever a column name could appear. Host variables are entered as either a '?' characters (unnamed host variables) or as ":name" (named host variable). In the example, SELECT * FROM SampleTable WHERE pk > :bound AND pk < ? there are two host variables which may be set using the PreparedStatement that was prepared for the SQL statement in question. |
close 方法
execute 方法
executeQuery 方法
getBlobOutputStream 方法
getClobWriter 方法
getOrdinal 方法
getPlan 方法
getPlanTree 方法
getResultSet 方法
getUpdateCount 方法
hasResultSet 方法
set 方法
setNull 方法
![]() |
使用DocCommentXchange 讨论此页。
|
版权 © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |