diff --git a/src/osm/jp/coverage/fuel/ToPostgis.java b/src/osm/jp/coverage/fuel/ToPostgis.java index bb7bb91..3884ee6 100644 --- a/src/osm/jp/coverage/fuel/ToPostgis.java +++ b/src/osm/jp/coverage/fuel/ToPostgis.java @@ -10,6 +10,8 @@ import javax.xml.parsers.ParserConfigurationException; import jp.co.areaweb.tools.database.DatabaseTool; import org.xml.sax.SAXException; +import osm.jp.api.HttpPOST; +import static osm.jp.coverage.busstop.ToPostgis.toInsert; /** * 国土数値情報から読み取ったデータをPostGISへインサートするためのSQLファイルに出力する。 @@ -79,10 +81,17 @@ } public static void transportNew (Connection conHsql, Connection conPost) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException { - try (PreparedStatement ps2 = conPost.prepareStatement("DELETE FROM t_FUEL")) { - System.out.println("DELETE FROM t_FUEL;"); - ps2.executeUpdate(); - } + HttpPOST httpPOST = new HttpPOST(conPost, null); + httpPOST.sql("DROP TABLE IF EXISTS t_FUEL CASCADE;"); + httpPOST.sql("CREATE TABLE t_FUEL (" + + "gid SERIAL PRIMARY KEY," + + "idref text, " + + "gmlid text, " + + "name text, " + + "fixed integer," + + "area integer," + + "geom GEOMETRY(POINT, 4612));"); + httpPOST.sql("CREATE INDEX ix_fuel_geom ON t_FUEL USING GiST (geom);"); toInsert(conHsql, conPost); } diff --git a/src/osm/jp/coverage/police/DbPolice.java b/src/osm/jp/coverage/police/DbPolice.java index a981345..72a5c4d 100644 --- a/src/osm/jp/coverage/police/DbPolice.java +++ b/src/osm/jp/coverage/police/DbPolice.java @@ -30,8 +30,6 @@ File dir = null; /** メイン - * 動作条件; HSQLDBのフォルダを削除した状態で実行すること。 - * フォルダを削除しないで実行する場合は「-DROP」オプションを使うこと * @param args * @throws IOException * @throws SQLException @@ -41,11 +39,10 @@ * @throws org.xml.sax.SAXException */ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, IOException, SQLException, ParserConfigurationException, SAXException { - File dir = new File("database"); - if (dir.exists()) { - if (dir.isDirectory()) { - DeleteDir.delete(dir); - } + // HSQLディレクトリがなければエラー + File dbdir = new File("database"); + if (!dbdir.isDirectory()) { + throw new FileNotFoundException("Directory 'database' is not found."); } Connection conHsql = null; diff --git a/src/osm/jp/coverage/postoffice/DbPostoffice.java b/src/osm/jp/coverage/postoffice/DbPostoffice.java index 80c0e6e..0e518f0 100644 --- a/src/osm/jp/coverage/postoffice/DbPostoffice.java +++ b/src/osm/jp/coverage/postoffice/DbPostoffice.java @@ -32,11 +32,10 @@ * @throws org.xml.sax.SAXException */ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, IOException, SQLException, ParserConfigurationException, SAXException { - File dir = new File("database"); - if (dir.exists()) { - if (dir.isDirectory()) { - DeleteDir.delete(dir); - } + // HSQLディレクトリがなければエラー + File dbdir = new File("database"); + if (!dbdir.isDirectory()) { + throw new FileNotFoundException("Directory 'database' is not found."); } Connection con = null;