Java examples for JDBC:SQL Warning
We can retrieve SQL Warnings from a Connection, Statement or ResultSet object.
import java.sql.Connection; import java.sql.SQLWarning; public class Main { public static void main(String[] args) throws Exception { Connection conn = null; SQLWarning warning = conn.getWarnings(); while (warning != null) { int errorCode = warning.getErrorCode(); String sqlState = warning.getSQLState(); String warningMsg = warning.getMessage(); // Print the details System.out.println("Warning: " + warningMsg + "SQL State: " + sqlState + "Error Code:" + errorCode); // Get the next warning warning = warning.getNextWarning(); } } }