• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

巨大森林を分割する


Commit MetaInfo

Revisãoc771d838e51acea432e1f5d1f4cd55b061a7a90b (tree)
Hora2013-08-03 10:36:43
Autorhayashi.yuu <hayashi.yuu@gmai...>
Commiterhayashi.yuu

Mensagem de Log

テーブルをCREATEする前にテーブルの存在を確認する

Mudança Sumário

Diff

--- a/osmCutter.sh
+++ b/osmCutter.sh
@@ -1,4 +1,3 @@
11 #!/bin/sh
2-rm -r database
3- java -cp .:OsmCutter.jar:../hayashi_0225.jar:../hsqldb.jar osm.jp.RelationCutter natural_wood_kanagawa.osm > out.txt
2+ java -cp .:OsmCutter.jar:../hayashi_0225.jar:../hsqldb.jar osm.jp.RelationCutter natural_wood_kanagawa.osm
43 #java -cp .:OsmCutter.jar:../hayashi_0225.jar:../hsqldb.jar osm.jp.RelationCutter koubouyama159740689.osm
\ No newline at end of file
--- a/src/osm/jp/DbBigrelation.java
+++ b/src/osm/jp/DbBigrelation.java
@@ -2,6 +2,7 @@ package osm.jp;
22
33 import java.io.*;
44 import java.sql.Connection;
5+import java.sql.DatabaseMetaData;
56 import java.sql.PreparedStatement;
67 import java.sql.ResultSet;
78 import java.sql.SQLException;
@@ -33,6 +34,8 @@ public class DbBigrelation
3334 Connection con = null;
3435 try {
3536 con = DatabaseTool.openDb("database");
37+ DbBigrelation.isTable(con, "NODE");
38+ DbBigrelation.initDb(con);
3639 DbBigrelation.export(con);
3740 }
3841 finally {
@@ -58,10 +61,36 @@ public class DbBigrelation
5861 * @throws SQLException
5962 */
6063 public static void create(Connection con) throws SQLException {
61- create_NODE(con);
62- create_TAG(con);
63- create_NDREF(con);
64- create_MEMBER(con);
64+ if (!isTable(con, "NODE")) {
65+ create_NODE(con);
66+ }
67+ if (!isTable(con, "TAG")) {
68+ create_TAG(con);
69+ }
70+ if (!isTable(con, "NDREF")) {
71+ create_NDREF(con);
72+ }
73+ if (!isTable(con, "MEMBER")) {
74+ create_MEMBER(con);
75+ }
76+ }
77+
78+ /**
79+ * DATABASE.TABLEが存在するかどうか調べる
80+ */
81+ public static boolean isTable(Connection con, String tableName) throws SQLException {
82+ boolean isTable = false;
83+ DatabaseMetaData dmd = con.getMetaData();
84+ ResultSet rs = dmd.getTables(null, null, tableName, null);
85+ try {
86+ while (rs.next()) {
87+ isTable = true;
88+ }
89+ } finally {
90+ rs.close();
91+ }
92+ System.out.println("\tisTable(" + tableName + ")\t"+ Boolean.toString(isTable));
93+ return isTable;
6594 }
6695
6796 /**