How to throw multiple exceptions in Java?

You cannot throw multiple exceptions at the same time in Java, but you can throw multiple different exceptions at different times.

Here's how you do it:

public void myMethod() throws IOException, SQLException {
  // …

  if (/* some condition */) {
    throw new IOException("first exception");
  }

  // …

  if (/* another condition */){
    throw new SQLException("second exception");
  }

  // …
}