boolean connectToDB = false;
// run first, in EDT:
public void init() {
DBStrings dbs = metaData.getDBStrings();
// get DBStrings from user if necessary
if (!dbs.isConfigValid()) {
// init DB strings if necessary
if (! dbs.isInitialized()) {
dbs.initialize();
}
// show connection dialog
DBConnectDialog dbd = new DBConnectDialog(frame(), dbs);
Util.placeDialog(dbd, BasePanel.this );
dbd.setVisible(true);
connectToDB = dbd.getConnectToDB();
// store database strings
if (connectToDB) {
dbs = dbd.getDBStrings();
metaData.setDBStrings(dbs);
dbd.dispose();
}
} else {
connectToDB = true;
}
}
// run second, on a different thread:
public void run() {
if (connectToDB) {
DBStrings dbs = metaData.getDBStrings();
try {
frame.output(Globals.lang("Attempting SQL export..."));
SQLutil.exportDatabase(database, metaData, null, dbs);
dbs.isConfigValid(true);
} catch (Exception ex) {
errorMessage = SQLutil.getExceptionMessage(ex,SQLutil.DBTYPE.MYSQL);
dbs.isConfigValid(false);
}
metaData.setDBStrings(dbs);