--- android/TrainInfoService/src/dk/thoerup/traininfoservice/db/StationDAO.java 2011/05/02 16:08:01 1416 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/db/StationDAO.java 2011/05/02 16:21:37 1417 @@ -258,6 +258,7 @@ return result; } + @Deprecated public static String getStationName(int stationID) { String station = ""; @@ -280,7 +281,43 @@ return station; } + + public StationEntry getSimpleByName(String name) throws SQLException { + String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0 " + + "FROM trainstations " + + "WHERE name = ? AND enabled = true " + + "LIMIT 1 "; + + StationBean result; + Connection conn = null; + PreparedStatement stmt = null; + ResultSet res = null; + try { + conn = DBConnection.getConnection(); + stmt = conn.prepareStatement(SQL); + + stmt.setString(1, name ); + + res = stmt.executeQuery(); + result = convertResultset(res); + + } finally { + if (res != null) + res.close(); + if (stmt != null) + stmt.close(); + if (conn!= null) + conn.close(); + } + + if (result.entries.size() == 1) { + return result.entries.get(0); + } else { + return null; + } + } + @Deprecated public int getIdByName(String name) throws SQLException { String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0 " + "FROM trainstations " +