Processing Dynamic SQL
The
overriding
concept introduced in Example 13-6 is the dynamic SQL
call. Because we do not know whether we will be processing a query or
an update, we need to pass the SQL call through the execute(
)
method. This method returns
true if the statement returned a result set or
false if none was produced. In the example, if it
returns true, the application gets the returned
ResultSet through a call to getResultSet(
)
.
The application can then go on to do normal result set processing.
If, on the other hand, the statement performed some sort of database
modification, you can call getUpdateCount(
)
to find out how many rows were modified by the statement.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access