40 |
"FROM trainstations WHERE id=" + id + " AND enabled=true"; |
"FROM trainstations WHERE id=" + id + " AND enabled=true"; |
41 |
|
|
42 |
Connection conn = null; |
Connection conn = null; |
43 |
|
Statement stmt = null; |
44 |
|
ResultSet res = null; |
45 |
StationBean result; |
StationBean result; |
46 |
|
|
47 |
try { |
try { |
48 |
conn = DBConnection.getConnection(); |
conn = DBConnection.getConnection(); |
49 |
|
|
50 |
Statement stmt = conn.createStatement(); |
stmt = conn.createStatement(); |
51 |
ResultSet res = stmt.executeQuery(SQL); |
res = stmt.executeQuery(SQL); |
52 |
res.next(); |
res.next(); |
53 |
result = convertSingleRow(res); |
result = convertSingleRow(res); |
54 |
} finally { |
} finally { |
55 |
|
if (res != null) |
56 |
|
res.close(); |
57 |
|
if (stmt != null) |
58 |
|
stmt.close(); |
59 |
if (conn != null) |
if (conn != null) |
60 |
conn.close(); |
conn.close(); |
61 |
} |
} |
73 |
|
|
74 |
List<StationBean> result; |
List<StationBean> result; |
75 |
Connection conn = null; |
Connection conn = null; |
76 |
|
PreparedStatement stmt = null; |
77 |
|
ResultSet res = null; |
78 |
try { |
try { |
79 |
conn = DBConnection.getConnection(); |
conn = DBConnection.getConnection(); |
80 |
PreparedStatement stmt = conn.prepareStatement(SQL); |
stmt = conn.prepareStatement(SQL); |
81 |
|
|
82 |
stmt.setString(1, name + "%"); |
stmt.setString(1, name + "%"); |
83 |
|
|
84 |
ResultSet rs = stmt.executeQuery(); |
res = stmt.executeQuery(); |
85 |
result = convertResultset(rs); |
result = convertResultset(res); |
86 |
|
|
87 |
} finally { |
} finally { |
88 |
if (conn != null) |
if (res != null) |
89 |
|
res.close(); |
90 |
|
if (stmt != null) |
91 |
|
stmt.close(); |
92 |
|
if (conn!= null) |
93 |
conn.close(); |
conn.close(); |
94 |
} |
} |
95 |
return result; |
return result; |
106 |
"LIMIT 4 "; |
"LIMIT 4 "; |
107 |
List<StationBean> result; |
List<StationBean> result; |
108 |
Connection conn = null; |
Connection conn = null; |
109 |
|
PreparedStatement stmt = null; |
110 |
|
ResultSet res = null; |
111 |
try { |
try { |
112 |
conn = DBConnection.getConnection(); |
conn = DBConnection.getConnection(); |
113 |
PreparedStatement stmt = conn.prepareStatement(SQL); |
stmt = conn.prepareStatement(SQL); |
114 |
stmt.setDouble(1, latitude); |
stmt.setDouble(1, latitude); |
115 |
stmt.setDouble(2, longitude); |
stmt.setDouble(2, longitude); |
116 |
ResultSet rs = stmt.executeQuery(); |
res = stmt.executeQuery(); |
117 |
result = convertResultset(rs); |
result = convertResultset(res); |
118 |
|
|
119 |
} finally { |
} finally { |
120 |
if (conn != null) |
if (res != null) |
121 |
|
res.close(); |
122 |
|
if (stmt != null) |
123 |
|
stmt.close(); |
124 |
|
if (conn!= null) |
125 |
conn.close(); |
conn.close(); |
126 |
} |
} |
127 |
return result; |
return result; |
134 |
"ORDER BY name "; |
"ORDER BY name "; |
135 |
|
|
136 |
Connection conn = null; |
Connection conn = null; |
137 |
|
Statement stmt = null; |
138 |
|
ResultSet res = null; |
139 |
List<StationBean> result; |
List<StationBean> result; |
140 |
|
|
141 |
try { |
try { |
142 |
conn = DBConnection.getConnection(); |
conn = DBConnection.getConnection(); |
143 |
Statement stmt = conn.createStatement(); |
stmt = conn.createStatement(); |
144 |
ResultSet res = stmt.executeQuery(SQL); |
res = stmt.executeQuery(SQL); |
145 |
result = convertResultset(res); |
result = convertResultset(res); |
146 |
} finally { |
} finally { |
147 |
|
if (res != null) |
148 |
|
res.close(); |
149 |
|
if (stmt != null) |
150 |
|
stmt.close(); |
151 |
if (conn!= null) |
if (conn!= null) |
152 |
conn.close(); |
conn.close(); |
153 |
} |
} |
155 |
return result; |
return result; |
156 |
|
|
157 |
} |
} |
158 |
|
public static String getStationName(int stationID) { |
159 |
|
String station = ""; |
160 |
|
|
161 |
|
Connection conn = null; |
162 |
|
try { |
163 |
|
conn = DBConnection.getConnection(); |
164 |
|
Statement stmt = conn.createStatement(); |
165 |
|
ResultSet rs = stmt.executeQuery("SELECT name FROM trainstations WHERE id=" + stationID); |
166 |
|
if (rs.next()) { |
167 |
|
station = rs.getString(1); |
168 |
|
} |
169 |
|
|
170 |
|
} catch (Exception e) { |
171 |
|
} finally { |
172 |
|
try { |
173 |
|
if (conn != null && !conn.isClosed()) |
174 |
|
conn.close(); |
175 |
|
} catch (Exception e) {} |
176 |
|
} |
177 |
|
|
178 |
|
return station; |
179 |
|
} |
180 |
} |
} |