new SQLWarning(String reason) : SQLWarning « java.sql « Java by API






new SQLWarning(String reason)

  

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;
  }

}

   
    
  








Related examples in the same category

1.SQLWarning: getNextWarning()
2.SQLWarning: setNextWarning(SQLWarning w)