OSDN Git Service

fix: gpx name is correct
authorhayashi <hayashi.yuu@gmail.com>
Sat, 7 Jun 2014 08:05:42 +0000 (17:05 +0900)
committerhayashi <hayashi.yuu@gmail.com>
Sat, 7 Jun 2014 08:05:42 +0000 (17:05 +0900)
src/osm/jp/ConvBusstop.java

index 1450df4..8d66832 100644 (file)
@@ -631,8 +631,7 @@ public class ConvBusstop {
        public static void showBusStop(Connection con, Node node, String iFileName) throws IOException, SQLException {
                String idrefStr = "";
                String nameStr = "";
-               PreparedStatement ps1 = con.prepareStatement("SELECT idref FROM bus_stop WHERE idref=?");
-               PreparedStatement ps2 = con.prepareStatement("INSERT INTO bus_stop (idref,name,ifile) VALUES (?,?,?)");
+               PreparedStatement ps2 = con.prepareStatement("UPDATE bus_stop SET name=?,ifile=? WHERE idref=?");
                PreparedStatement ps3 = con.prepareStatement("SELECT code FROM bus_course WHERE course=? AND corp=? AND ifile=?");
                PreparedStatement ps4 = con.prepareStatement("INSERT INTO bus_course (code,type,corp,course,ifile) VALUES (?,?,?,?,?)");
                PreparedStatement ps5 = con.prepareStatement("INSERT INTO bus_ref (idref,code) VALUES (?,?)");
@@ -667,27 +666,17 @@ public class ConvBusstop {
                }
 
                // idref と nameStr をデータベースに格納する
-               boolean insert = false;
-               ps1.setString(1, idrefStr);
-               ResultSet rset = ps1.executeQuery();
-               if (!rset.next()) {
-                       insert = true;
-               }
-               rset.close();
-
-               if (insert) {
-                       ps2.setString(1, idrefStr);
-                       ps2.setString(2, nameStr);
-                       ps2.setString(3, iFileName);
-                       ps2.executeUpdate();
-               }
+               ps2.setString(1, nameStr);
+               ps2.setString(2, iFileName);
+               ps2.setString(3, idrefStr);
+               ps2.executeUpdate();
 
                for (String[] rtn : bris) {
                        int code = 0;
                        ps3.setString(1, rtn[1]);
                        ps3.setString(2, rtn[2]);
                        ps3.setString(3, iFileName);
-                       rset = ps3.executeQuery();
+                       ResultSet rset = ps3.executeQuery();
                        if (rset.next()) {
                                code = rset.getInt(1);
                        }
@@ -716,7 +705,6 @@ public class ConvBusstop {
                        ps5.executeUpdate();
                }
 
-               ps1.close();
                ps2.close();
                ps3.close();
                ps4.close();
@@ -877,10 +865,10 @@ public class ConvBusstop {
                                latStr = str4Ary[0];
                                lonStr = str4Ary[1];
                                
-                               PreparedStatement ps6 = con.prepareStatement("UPDATE bus_stop SET lat=?,lon=?,fixed=? WHERE idref=?");
+                               PreparedStatement ps6 = con.prepareStatement("INSERT INTO bus_stop (lat,lon,fixed,idref) VALUES (?,?,?,?)");
                                double lat = Double.parseDouble(latStr);
                                double lon = Double.parseDouble(lonStr);
-                               System.out.println("UPDATE bus_stop SET lat='"+ latStr +"',lon='"+ lonStr +"',fixed='"+ (ConvBusstop.nocheck ? 0 : HttpGET.getMap(lat, lon, NEER)) +"' WHERE idref='"+ idStr +"'");
+                               System.out.println("INSERT INTO bus_stop (lat,lon,fixed,idref) VALUES ('"+ latStr +"','"+ lonStr +"','"+ (ConvBusstop.nocheck ? 0 : HttpGET.getMap(lat, lon, NEER)) +"','"+ idStr +"')");
 
                                ps6.setDouble(1, lat);
                                ps6.setDouble(2, lon);