diff --git a/src/osm/jp/coverage/fuel/DbExist.java b/src/osm/jp/coverage/fuel/DbExist.java index bc47ffc..862618f 100644 --- a/src/osm/jp/coverage/fuel/DbExist.java +++ b/src/osm/jp/coverage/fuel/DbExist.java @@ -16,8 +16,8 @@ import org.xml.sax.SAXException; import osm.jp.api.Db; -public class DbFuel { - public static final String TABLE_NAME = "FUEL"; +public class DbExist { + public static final String TABLE_NAME = "FUEL_EXIST"; /** メイン * @param args @@ -29,11 +29,6 @@ * @throws org.xml.sax.SAXException */ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, IOException, SQLException, ParserConfigurationException, SAXException { - // HSQLディレクトリがなければ作る - File dbdir = new File("database"); - if (!dbdir.isDirectory()) { - dbdir.mkdir(); - } Connection con = null; try { // DB.tableを作成 @@ -50,7 +45,7 @@ } } - DbFuel.export(con); + DbExist.export(con); } finally { if (con != null) { @@ -198,7 +193,7 @@ } /** - * 'table.FUEL'を新規に作る + * 'table.FUEL_EXIST'を新規に作る * 既にテーブルが存在する時には何もしない * @param con * @throws SQLException @@ -206,16 +201,11 @@ public static void create(Connection con) throws SQLException { String createSt; - // 'table.FUEL'を新規に作る - //Db.drop(con, TABLE_NAME); - createSt = "CREATE TABLE "+ TABLE_NAME +" (idref VARCHAR(12) NOT NULL, lat DOUBLE, lon DOUBLE, fixed INT, area INT)"; + // 'table.FUEL_EXIST'を新規に作る + createSt = "CREATE TABLE "+ TABLE_NAME +" (idref VARCHAR(12) NOT NULL, lat DOUBLE, lon DOUBLE, score INT PRIMARY KEY(lat, lon));"; Db.updateSQL(con, createSt); /* - drop(con, "existing_data"); - createSt = "CREATE TABLE existing_data (idref VARCHAR(12) NOT NULL, name VARCHAR(128), lat DOUBLE, lon DOUBLE, score INT, CONSTRAINT existing_pk PRIMARY KEY(idref, lat, lon));"; - Db.updateSQL(con, createSt); - drop(con, "coverage"); createSt = "CREATE TABLE coverage (area INT, name VARCHAR(128), denominator BIGINT, lv1 BIGINT, lv2 BIGINT, lv3 BIGINT);"; Db.updateSQL(con, createSt); @@ -228,18 +218,17 @@ * @throws java.sql.SQLException */ public static void export(Connection con) throws SQLException { - String header = "idref,lat,lon,fixed"; + String header = "idref,lat,lon,score"; System.out.println("TABLE: "+ TABLE_NAME); System.out.println(header); - PreparedStatement ps8 = con.prepareStatement("SELECT idref,lat,lon,fixed,area FROM "+ TABLE_NAME); + PreparedStatement ps8 = con.prepareStatement("SELECT idref,lat,lon,score FROM "+ TABLE_NAME); try (ResultSet rset8 = ps8.executeQuery()) { while (rset8.next()) { String name = rset8.getString(1); Double lat = rset8.getDouble(2); Double lon = rset8.getDouble(3); - int fixed = rset8.getInt(4); - int area = rset8.getInt(5); - System.out.println(name +","+ lat +","+ lon +","+ fixed+","+ area); + int score = rset8.getInt(4); + System.out.println(name +","+ lat +","+ lon +","+ score); } } }