Revisión | 2242bf762814c10a6b21b064a5761bb27abdaee3 (tree) |
---|---|
Tiempo | 2017-01-15 09:14:14 |
Autor | yuuhayashi <hayashi.yuu@gmai...> |
Commiter | yuuhayashi |
postgresql 用に(')をエスケープする
@@ -1248,7 +1248,7 @@ public class ConvBusstop { | ||
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | /** |
1251 | - * OSMデータファイルかどうかを見極める | |
1251 | + * 数値地図情報のデータファイルかどうかを見極める | |
1252 | 1252 | * @param f |
1253 | 1253 | * @return |
1254 | 1254 | */ |
@@ -48,7 +48,7 @@ public class ToPostgis { | ||
48 | 48 | int areacode = rset8.getInt("area"); |
49 | 49 | |
50 | 50 | counter++; |
51 | - String osm_node = "insert into t_busstop(name,fixed,area,geom) VALUES('"+ name +"',"+ fixed +","+ areacode +", ST_GeomFromText('POINT("+ Double.toString(lon) +" "+ Double.toString(lat) +")', 4612));"; | |
51 | + String osm_node = "insert into t_busstop(name,fixed,area,geom) VALUES('"+ escapeStr(name) +"',"+ fixed +","+ areacode +", ST_GeomFromText('POINT("+ Double.toString(lon) +" "+ Double.toString(lat) +")', 4612));"; | |
52 | 52 | System.out.println(osm_node); |
53 | 53 | this.ow.write(osm_node); |
54 | 54 | this.ow.newLine(); |
@@ -58,6 +58,16 @@ public class ToPostgis { | ||
58 | 58 | return counter; |
59 | 59 | } |
60 | 60 | |
61 | + /** | |
62 | + * postgresql 用に(')をエスケープする | |
63 | + * | |
64 | + * @param name | |
65 | + * @return | |
66 | + */ | |
67 | + public String escapeStr(String name) { | |
68 | + return name.replaceAll("'", "''"); | |
69 | + } | |
70 | + | |
61 | 71 | public void close() { |
62 | 72 | try { |
63 | 73 | this.ow.close(); |