import java.sql.SQLException; 
import java.sql.SQLWarning; 
 
public class Main { 
 
  public static void main(String[] args) { 
    try { 
      throwWarning(); 
    } catch (SQLException e) { 
      System.err.println("An SQL exception occurred: " + e); 
      e.printStackTrace(); 
      while ((e = e.getNextException()) != null) { 
        System.err.println("Contained reason: " + e); 
      } 
    } 
  } 
 
  private static void throwWarning() throws SQLException { 
    SQLWarning rootWarning = new SQLWarning("Outter warning"); 
    SQLWarning containedWarning = new SQLWarning("Inner warning"); 
    rootWarning.setNextWarning(containedWarning); 
    throw rootWarning; 
  } 
 
} 
 
    
     
  
  |