Reputation: 13108
Since the following method returns a boolean, I would like to know how can I get a ResultSet
out of it if the method returns true
hence it is a ResultSet
execute
boolean execute(String sql)
throws SQLException
Upvotes: 0
Views: 1605
Reputation: 68715
When using execute
method, you can get the resultset(s)
by using : Statement.getResultSet
. Here are the details from javadoc:
execute: Returns true if the first object that the query returns is a ResultSet object. Use this method if the query could return one or more ResultSet objects. Retrieve the ResultSet objects returned from the query by repeatedly calling Statement.getResultSet.
Upvotes: 2
Reputation: 42020
To execute a query, call an execute method from
Statement
such as the following:
execute
: Returnstrue
if the first object that the query returns is aResultSet
object. Use this method if the query could return one or moreResultSet
objects. Retrieve theResultSet
objects returned from the query by repeatedly callingStatement.getResultSet
.executeQuery
: Returns oneResultSet
object.executeUpdate
: Returns an integer representing the number of rows affected by the SQL statement. Use this method if you are usingINSERT
,DELETE
, orUPDATE
SQL statements.
Trail: JDBC Database Access (The Java Tutorials)
Upvotes: 2
Reputation: 8473
Call getResultSet method of Statement
object if execute returns true.
Accroding to Statement#execute
The execute method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).
Upvotes: 1