7 |
import java.sql.Statement; |
import java.sql.Statement; |
8 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
9 |
|
|
10 |
|
import javax.jdo.PersistenceManager; |
11 |
|
|
12 |
import dk.thoerup.android.traininfo.common.StationBean; |
import dk.thoerup.android.traininfo.common.StationBean; |
13 |
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
14 |
|
import dk.thoerup.traininfoservice.jdo.JdoStationBean; |
15 |
|
import dk.thoerup.traininfoservice.jdo.PMF; |
16 |
|
|
17 |
public class StationDAO { |
public class StationDAO { |
18 |
final static int LOCATION_LIMIT = 8; |
final static int LOCATION_LIMIT = 8; |
49 |
} |
} |
50 |
|
|
51 |
|
|
52 |
public StationEntry getById(int id) throws SQLException { |
public JdoStationBean getById(int id) throws SQLException { |
|
String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0 " + |
|
|
"FROM trainstations WHERE id=" + id + " AND enabled=true"; |
|
|
|
|
|
Connection conn = null; |
|
|
Statement stmt = null; |
|
|
ResultSet res = null; |
|
|
StationEntry result; |
|
53 |
|
|
54 |
|
PersistenceManager pm = null; |
55 |
|
|
56 |
try { |
try { |
57 |
conn = DBConnection.getConnection(); |
pm = PMF.get().getPersistenceManager(); |
58 |
|
return pm.getObjectById(JdoStationBean.class, new Integer(id) ); |
|
stmt = conn.createStatement(); |
|
|
res = stmt.executeQuery(SQL); |
|
|
res.next(); |
|
|
result = convertSingleRow(res); |
|
59 |
} finally { |
} finally { |
60 |
if (res != null) |
pm.close(); |
|
res.close(); |
|
|
if (stmt != null) |
|
|
stmt.close(); |
|
|
if (conn != null) |
|
|
conn.close(); |
|
61 |
} |
} |
|
|
|
|
return result; |
|
62 |
} |
} |
63 |
|
|
64 |
/* |
/* |