* Client cards db will be compressed nos as you close XMage client.

This commit is contained in:
LevelX2 2014-12-31 15:57:18 +01:00
parent 41b6a41fda
commit f2a9a75e8f
2 changed files with 14 additions and 1 deletions

View file

@ -962,6 +962,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
return;
}
}
CardRepository.instance.closeDB();
Plugins.getInstance().shutdown();
dispose();
System.exit(0);

View file

@ -34,9 +34,11 @@ import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.stmt.SelectArg;
import com.j256.ormlite.stmt.Where;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.support.DatabaseConnection;
import com.j256.ormlite.table.TableUtils;
import java.io.File;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -56,7 +58,7 @@ public enum CardRepository {
private static final String JDBC_URL = "jdbc:h2:file:./db/cards.h2;AUTO_SERVER=TRUE";
private static final String VERSION_ENTITY_NAME = "card";
private static final long CARD_DB_VERSION = 35;
private static final long CARD_DB_VERSION = 36;
private final Random random = new Random();
private Dao<CardInfo, Object> cardDao;
@ -274,4 +276,14 @@ public enum CardRepository {
}
return new ArrayList<>();
}
public void closeDB() {
try {
DatabaseConnection conn = cardDao.getConnectionSource().getReadWriteConnection();
conn.executeStatement("shutdown compact", 0);
} catch (SQLException ex) {
}
}
}