I use DAO's to acces my database, and those dao methods throw SQL Exception, so i make it so that dao methods throw this exception.
Then i acces DAO's through Services, to it looks like:
public class UserService implements Service {
public int addNewUser(String username, String password) throws SQLException {
User user = new User(username, password);
UserDao dao = new UserDao(source.getConnection());
return dao.add(user);
}
}
Those methods throw exception too, but this way i have to handle SQL Exception in many places and sometimes it looks quite bad. Should i handle exception in service or dao? Or is it ok to check for an exception everywhere?