Raising Custom Sql Warning : SQL Warning « Database SQL JDBC « Java






Raising Custom Sql Warning

 
import java.sql.SQLException;
import java.sql.SQLWarning;

public class RasingCustomSqlWarning {

  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.Get Next SQL Warning()
2.Get SqlWarning Statement object
3.Determining If a SQL Warning Occurred