Don't shutdown database before all tables have done their own commit. Also rename count_by to a more Java-esque countBy.
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/AuctionEntry.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/util/db/ActiveRecord.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/util/db/Table.java view
| 569 | 575 | |
|---|---|---|
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | 1763 | public static int completedCount() { |
| 1764 | return getRealDatabase().count_by("ended = 1"); | |
| 1764 | return getRealDatabase().countBy("ended = 1"); | |
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | 1767 | private static final String snipeFinder = "(snipe_id IS NOT NULL OR multisnipe_id IS NOT NULL) AND ended != 1"; |
| 1768 | 1768 | |
| 1769 | 1769 | public static int snipedCount() { |
| 1770 | return getRealDatabase().count_by(snipeFinder); | |
| 1770 | return getRealDatabase().countBy(snipeFinder); | |
| 1771 | 1771 | } |
| 1772 | 1772 | |
| 1773 | 1773 | public static AuctionEntry nextSniped() { |
| 574 | 575 | |
|---|---|---|
| 6 | 6 | import java.util.Set; |
| 7 | 7 | import java.util.List; |
| 8 | 8 | import java.util.ArrayList; |
| 9 | import java.util.HashSet; | |
| 9 | 10 | import java.lang.reflect.Field; |
| 10 | 11 | |
| 11 | 12 | /** |
| --- | --- | |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | public static void shutdown() { |
| 35 | Set<Database> s = new HashSet<Database>(); | |
| 34 | 36 | for(Table t : sTables) { |
| 35 | t.shutdown(); | |
| 37 | s.add(t.shutdown()); | |
| 36 | 38 | } |
| 39 | for(Database db : s) { | |
| 40 | db.shutdown(); | |
| 41 | } | |
| 37 | 42 | } |
| 38 | 43 | |
| 39 | 44 | protected static Table getTable(Object o) { |
| 512 | 575 | |
|---|---|---|
| 62 | 62 | /** |
| 63 | 63 | * Close the statement, commit any last outstanding data (!?) and shut down the database. |
| 64 | 64 | */ |
| 65 | public void shutdown() { | |
| 65 | public Database shutdown() { | |
| 66 | 66 | try { |
| 67 | 67 | mS.close(); |
| 68 | 68 | } catch (SQLException e) { |
| 69 | 69 | ErrorManagement.handleException("Can't shut down database.", e); |
| 70 | 70 | } |
| 71 | 71 | mDB.commit(); |
| 72 | mDB.shutdown(); | |
| 72 | return mDB; | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public void commit() { |
| --- | --- | |
| 414 | 414 | return Integer.parseInt(count); |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | public int count_by(String condition) { | |
| 417 | public int countBy(String condition) { | |
| 418 | 418 | Record rm = findFirst("SELECT COUNT(*) AS count FROM " + mTableName + " WHERE " + condition); |
| 419 | 419 | String count = rm.get("count"); |
| 420 | 420 | return Integer.parseInt(count); |
