avatar

575

Don't shutdown database before all tables have done their own commit. Also rename count_by to a more Java-esque countBy.

by mrs, 25 Jul, 2008 10:23 PM
569 575  
17611761   }
17621762 
17631763   public static int completedCount() {
1764     return getRealDatabase().count_by("ended = 1");
1764     return getRealDatabase().countBy("ended = 1");
17651765   }
17661766 
17671767   private static final String snipeFinder = "(snipe_id IS NOT NULL OR multisnipe_id IS NOT NULL) AND ended != 1";
17681768 
17691769   public static int snipedCount() {
1770     return getRealDatabase().count_by(snipeFinder);
1770     return getRealDatabase().countBy(snipeFinder);
17711771   }
17721772 
17731773   public static AuctionEntry nextSniped() {
574 575  
66 import java.util.Set;
77 import java.util.List;
88 import java.util.ArrayList;
9 import java.util.HashSet;
910 import java.lang.reflect.Field;
1011 
1112 /**
------
3132   }
3233 
3334   public static void shutdown() {
35     Set<Database> s = new HashSet<Database>();
3436     for(Table t : sTables) {
35       t.shutdown();
37       s.add(t.shutdown());
3638     }
39     for(Database db : s) {
40       db.shutdown();
41     }
3742   }
3843 
3944   protected static Table getTable(Object o) {
512 575  
6262   /**
6363    * Close the statement, commit any last outstanding data (!?) and shut down the database.
6464    */
65   public void shutdown() {
65   public Database shutdown() {
6666     try {
6767       mS.close();
6868     } catch (SQLException e) {
6969       ErrorManagement.handleException("Can't shut down database.", e);
7070     }
7171     mDB.commit();
72     mDB.shutdown();
72     return mDB;
7373   }
7474 
7575   public void commit() {
------
414414     return Integer.parseInt(count);
415415   }
416416 
417   public int count_by(String condition) {
417   public int countBy(String condition) {
418418     Record rm = findFirst("SELECT COUNT(*) AS count FROM " + mTableName + " WHERE " + condition);
419419     String count = rm.get("count");
420420     return Integer.parseInt(count);