executeQuery 方法 (SQLServerStatement)executeQuery Method (SQLServerStatement)

下载下载 JDBC 驱动程序DownloadDownload JDBC Driver

运行给定的 SQL 语句并返回单一的 SQLServerResultSet 对象。Runs the given SQL statement and returns a single SQLServerResultSet object.

语法Syntax

  
public java.sql.ResultSet executeQuery(java.lang.String sql)  

参数Parameters

sqlsql

包含 SQL 语句的 String。A String that contains an SQL statement.

返回值Return Value

SQLServerResultSet 对象。A SQLServerResultSet object.

例外Exceptions

SQLServerExceptionSQLServerException

备注Remarks

此 executeQuery 方法是由 java.sql.Statement 接口中的 executeQuery 方法指定的。This executeQuery method is specified by the executeQuery method in the java.sql.Statement interface.

如果给定的 SQL 语句没有生成单一的 SQLServerResultSet 对象,则会引发 SQLServerExceptionSQLServerException is thrown if the given SQL statement produces anything other than a single SQLServerResultSet object.

如果执行存储过程将产生大于 1 的更新计数,或生成多个结果集,则请使用 execute 方法执行存储过程。If executing a stored procedure results in an update count that is greater than one, or that generates more than one result set, use the execute method to execute the stored procedure.

另请参阅See Also

SQLServerStatement 成员 SQLServerStatement Members
SQLServerStatement 类SQLServerStatement Class