我非常肯定,这之前工作,但日食说,它在投掷线有错误。java抛出检查异常?
try{}
}catch(Exception e){
throw e; }
在我的老学生项目中,我写道:
try {
Class.forName("org.postgresql.Driver");
this.connection = DriverManager.getConnection(
DataSource.getURL(), DataSource.getUserName(), DataSource.getPassword());
} catch (ClassNotFoundException e) {
System.out.println("Could not find driver to connect to database. Please make"
+ "sure the correseponding postgreSQLjdbc library is added.");
throw e;
} catch (SQLException e) {
System.out.println("Username or password is not correct");
throw e;
}
,它是完美的。
只有这种类型的作品,但它不是我想要的
throw new UnsupportedAddressTypeException();
它总是这样吗?我会彻底疯狂... – Aubergine
@Aubergine--它总是那样。一个方法声明检查它抛出/传播的异常的要求在1.0以后就已经在Java中,并且可能更早。你可能会发疯:-) –
我明白这一点! :-)喝咖啡时间。 – Aubergine