--- android/TrainInfoService/src/dk/thoerup/traininfoservice/StationDAO.java 2010/09/29 23:05:14 1144 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/StationDAO.java 2010/10/01 05:30:32 1145 @@ -12,6 +12,11 @@ import dk.thoerup.android.traininfo.common.StationBean.StationEntry; public class StationDAO { + + public static class NostationException extends Exception { + private static final long serialVersionUID = 1L; + } + final static int LOCATION_LIMIT = 8; static final Logger logger = Logger.getLogger(StationDAO.class.getName()); @@ -46,7 +51,7 @@ } - public StationEntry getById(int id) throws SQLException { + public StationEntry getById(int id) throws SQLException,NostationException { String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0 " + "FROM trainstations WHERE id=" + id + " AND enabled=true"; @@ -59,9 +64,13 @@ conn = DBConnection.getConnection(); stmt = conn.createStatement(); - res = stmt.executeQuery(SQL); - res.next(); - result = convertSingleRow(res); + res = stmt.executeQuery(SQL); + + if (res.next()) { + result = convertSingleRow(res); + } else { + throw new NostationException(); + } } finally { if (res != null) res.close();