Within the first catch block why we can't throw an Exception
object? Here RuntimeException
is working fine.
public class CirEx {
public Circle getCircle(int id) {
Connection conn = null;
try {
Class.forName("");
conn = DriverManager.getConnection("");
PreparedStatement pstmt = conn.prepareStatement("");
Circle circle = new Circle(1, "");
return circle;
} catch (Exception e) {
throw new RuntimeException(e);
// why we cann't do that.
// throw new Exception(e);
} finally {
try {
conn.close();
} catch (SQLException e) {
System.out.println(e);
}
}
}
}