--- android/TrainInfoService/src/dk/thoerup/traininfoservice/DumpResultSet.java 2010/05/18 15:17:13 732 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/DumpResultSet.java 2010/05/18 17:56:43 733 @@ -81,6 +81,38 @@ return sb.toString(); } + String dumpUpdate(String query) throws ServletException { + StringBuilder sb = new StringBuilder(); + + Connection conn = null; + Statement stmt = null; + try { + conn = DBConnection.getConnection(); + stmt = conn.createStatement(); + stmt.execute(query); + int count = stmt.getUpdateCount(); + + sb.append("

").append(query).append("

"); + sb.append("Affected rows: ").append(count); + } catch (Exception e) { + throw new ServletException(e); + } finally { + try { + if (stmt != null && !stmt.isClosed()) + stmt.close(); + } catch (Exception e) {} + + try { + if (conn != null && !conn.isClosed()) + conn.close(); + } catch (Exception e) {} + } + + return sb.toString(); + } + + + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String dump = req.getParameter("dump"); @@ -106,10 +138,12 @@ res = dumpResultset("SELECT * FROM trainstations WHERE address IS NULL or address = '' "); } else if (dump.equals("aliases")) { res = dumpResultset("SELECT * FROM trainstations WHERE aliases IS NOT null"); + } else if (dump.equals("updatecoords")) { + res = dumpUpdate("UPDATE trainstations SET earth_coord = ll_to_earth(latitude,longitude)"); } } if (res == null) { - res = "All
All with links
Missing coords
Duplicate stations
Disabled stations
No address
Has aliases"; + res = "All
All with links
Missing coords
Duplicate stations
Disabled stations
No address
Has aliases
update coords"; } resp.setContentType("text/html");