How to retrieve SQLWarning in java?
SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warning simply alerts the user when something did not happen as planned. A warning can be reported on a Connection, ResultSet and Statement object. Each of these classes has a getWarnings() method, which we must invoke in order to see the warning reported on the calling object.
SQLWarning statementWarning = statement.getWarnings();
while (statementWarning != null)
System.out.println("Error code: " + statementWarning.getErrorCode());
System.out.println("SQL State: " + statementWarning.getSQLState());
System.out.println("Warning Message: " + statementWarning.getMessage());
statementWarning = statementWarning.getNextWarning();
clearWarning() method is used to clear all the warning reported by the call of Connection, ResultSet, and Statement objects.