나는 이것이 이전에 잘 돌아 왔음을 확신하지만, eclipse는 throw 라인에 오류가 있다고 말한다. 내 옛날 학생 프로젝트에서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;
}
그것은 완벽했다.
만이 유형은 작동하지만, 아마도 당신의 방법은 이UnsupportedAddressTypeException
하지만 SQLException
및 ClassNotFoundException
을 던져 선언이다 내가
throw new UnsupportedAddressTypeException();
항상 그렇게 좋았습니까? 나는 완전히 미쳐 가고있다 ... – Aubergine
@Aubergine - 항상 그렇게했다. 메소드가 throw/propagate하는 확인 된 예외를 선언하는 요구 사항은 1.0 이후부터 Java에 있었을 것입니다. 당신은 너무 미쳤을 수도 있습니다 :-) –
나는 그것을 고맙다! :-) 커피 휴식 시간. – Aubergine