//{{{ Update to 2.20
if (SetupInfo.getProperty("lazy8ledger.lastRunVersion").compareTo("2.20") < 0) {
//lots of database changes to make
//need a connection to the database
WorkingDialog workDialog = new WorkingDialog(null);
workDialog.setVisible(true);
try {
DataConnection dc = new DataConnection(null);
if (dc == null || !dc.bIsConnectionMade) {
JOptionPane.showMessageDialog(null,
Translator.getTranslation("Could not connect to the database. Do not attempt to continue."),
Translator.getTranslation("Must restart"),
JOptionPane.PLAIN_MESSAGE);
isInStart=true;
return;
}
//copy old Activity table into new Activity2 table
//UniqNumGenerator uniqnum = new UniqNumGenerator(); // commented out since never used
Statement st = dc.con.createStatement();
ResultSet rsOldTrans = st.executeQuery(dc.filterSQL(
"SELECT CompId,Act_id,RegDate,InvDate,Notes,FileInfo FROM Activity ORDER BY CompId,Act_id"));
rsOldTrans.last();
int numRecs=rsOldTrans.getRow();
rsOldTrans.beforeFirst();
while (rsOldTrans.next()) {
PreparedStatement prepSt = dc.con.prepareStatement(
"INSERT INTO Activity2 (CompId,Act_id,PeriodId,RegDate,InvDate,Notes,FileInfo) VALUES (?,?,?,?,?,?,?)");
prepSt.setInt(1,rsOldTrans.getInt(1));
prepSt.setInt(2, rsOldTrans.getInt(2));
prepSt.setInt(3, 0);
prepSt.setDate(4, rsOldTrans.getDate(3));
prepSt.setDate(5, rsOldTrans.getDate(4));
prepSt.setString(6, rsOldTrans.getString(5));
prepSt.setString(7, rsOldTrans.getString(6));
prepSt.executeUpdate();
workDialog.SetProgress((rsOldTrans.getRow() * 100) / (numRecs));
}
//delete the old Activity table
st = dc.con.createStatement();
st.executeUpdate("DROP TABLE Activity");
SystemLog.ErrorPrintln("Dropped old table Activity");
} catch (Exception e) {
e.printStackTrace();
//we need to continue because otherwise this is a lock stoping proper usage of lazy8ledger forever
//return;
}
workDialog.dispose();
AdjustAllPeriodIds(0);
}//}}}
SetupInfo.setProperty("lazy8ledger.lastRunVersion",
jEdit.getProperty("plugin.lazy8ledger.Lazy8LedgerPlugin.version"));