X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fdb%2FSchema.java;h=898687ee4db5fd65112c10d6c39663b1891b4765;hp=4937fae153eae94dacf8c051c8c49d07b7775892;hb=58107a0cbb49652e7772ce80fb73d2c027590eb1;hpb=083fb5094456d37fa4765400a461625635fbf77d diff --git a/prod/net/jaekl/cfb/db/Schema.java b/prod/net/jaekl/cfb/db/Schema.java index 4937fae..898687e 100644 --- a/prod/net/jaekl/cfb/db/Schema.java +++ b/prod/net/jaekl/cfb/db/Schema.java @@ -41,12 +41,17 @@ public class Schema { } if (!postCreationInit(con)) { - + return false; } return true; } + public void purge(Connection con) throws SQLException { + dropAllTables(con); + dropAllSequences(con); + } + boolean postCreationInit(Connection con) throws SQLException { // no-op // Override this in a derived class if you need to initialize something @@ -90,6 +95,17 @@ public class Schema { return true; } + void dropAllTables(Connection con) { + for (Table table : m_tables) { + try { + m_driver.dropTable(con, table); + } + catch (SQLException e) { + e.printStackTrace(); + } + } + } + boolean createAllSequences(Connection con) throws SQLException { for (Sequence seq : m_sequences) { if (!m_driver.createSequence(con, seq)) { @@ -99,6 +115,17 @@ public class Schema { return true; } + void dropAllSequences(Connection con) { + for (Sequence seq : m_sequences) { + try { + m_driver.dropSequence(con, seq); + } + catch (SQLException e) { + e.printStackTrace(); + } + } + } + void addTable(Table table) { m_tables.add(table); }