Multiple choice technology programming languages

How do you know in your Java program that a SQL warning is generated as a result of executing a SQL statement in the database?

  1. You must catch the checked SQLException which is thrown by the method which executes

  2. You must catch the unchecked SQLWarningException which is thrown by the method

  3. You must invoke the getWarnings() method on the Statement object (or a sub interface

  4. You must query the ResultSet object about possible warnings generated by the database

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

SQL warnings in JDBC do not throw exceptions. Developers must call getWarnings() on the Statement, Connection, or ResultSet object to check for them. Distractors suggesting catching exceptions are wrong since warnings are silent.