我非常肯定,這之前工作,但日食說,它在投擲線有錯誤。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