Reputation: 3521
This question is an extension of this question. It is good that I can get MetaData. However reading the documentation I have understood that this data is only for SELECT type requests. And I need more information, is it UPDATE or SELECT and etc. Can I get this information without parsing SQL request? What will be if I use executeQuery() or getMetaData() to UPDATE or DELETE request?
Upvotes: 0
Views: 510
Reputation: 24012
Meta data is available only on ResultSet
and Database
level but not on Update
and Delete
type of queries. The Statement.execute( String sql )
can be used to identify if the query returns ResultSet(s)
or an integer amount of records affected.
Documentation says:
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).
This method returns true if the first result is a ResultSet object; false if it is an update count or there are no results
There is no any direct method that tells you if the query being is used is an Update
or a Delete
. You require to parse it explicit and identify.
Upvotes: 1