12 |
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
13 |
|
|
14 |
public class StationDAO { |
public class StationDAO { |
15 |
|
|
16 |
|
public static class NostationException extends Exception { |
17 |
|
private static final long serialVersionUID = 1L; |
18 |
|
} |
19 |
|
|
20 |
final static int LOCATION_LIMIT = 8; |
final static int LOCATION_LIMIT = 8; |
21 |
static final Logger logger = Logger.getLogger(StationDAO.class.getName()); |
static final Logger logger = Logger.getLogger(StationDAO.class.getName()); |
22 |
|
|
51 |
} |
} |
52 |
|
|
53 |
|
|
54 |
public StationEntry getById(int id) throws SQLException { |
public StationEntry getById(int id) throws SQLException,NostationException { |
55 |
String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0 " + |
String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0 " + |
56 |
"FROM trainstations WHERE id=" + id + " AND enabled=true"; |
"FROM trainstations WHERE id=" + id + " AND enabled=true"; |
57 |
|
|
64 |
conn = DBConnection.getConnection(); |
conn = DBConnection.getConnection(); |
65 |
|
|
66 |
stmt = conn.createStatement(); |
stmt = conn.createStatement(); |
67 |
res = stmt.executeQuery(SQL); |
res = stmt.executeQuery(SQL); |
68 |
res.next(); |
|
69 |
result = convertSingleRow(res); |
if (res.next()) { |
70 |
|
result = convertSingleRow(res); |
71 |
|
} else { |
72 |
|
throw new NostationException(); |
73 |
|
} |
74 |
} finally { |
} finally { |
75 |
if (res != null) |
if (res != null) |
76 |
res.close(); |
res.close(); |