avatar

954

Handle switching back and forth between MySQL and Derby. It's a Really Bad Idea, as once the databases are created they won't repopulate from the auctions.xml file, so data won't get migrated between them, but you can do it. Generally, though, you want a database change to be a one-time, permanent thing.

by mrs, 09 Jun, 2009 09:05 PM
951 954  
11 package com.jbidwatcher.ui.config;
22 
33 import com.jbidwatcher.util.config.JConfig;
4 import com.jbidwatcher.ui.util.OptionUI;
45 
56 import javax.swing.*;
67 import java.awt.event.ActionListener;
------
1920 public class JConfigDatabaseTab extends JConfigTab {
2021   private JRadioButton defaultDerbyDB;
2122   private JRadioButton mysqlDB;
23   private OptionUI mOui = null;
2224 
2325   private JTextField mysqlHost, mysqlPort;
2426   private JTextField mysqlDatabase;
------
6163     updateValues();
6264   }
6365 
64   //
65   //  Apply all changes made to the firewall options.  This does NOT
66   //  immediately open a SOCKS server, or a web proxy for all future
67   //  transactions.  It should.  HACKHACK -- mrs: 14-August-2001 01:44
68   //
6966   public boolean apply() {
7067     if (defaultDerbyDB.isSelected()) {
71       JConfig.kill("db.protocol");
72       JConfig.kill("db.driver");
73       JConfig.kill("db.user");
74       JConfig.kill("db.pass");
68       if(JConfig.queryConfiguration("temp.db.switch2derby") != null) JConfig.kill("temp.db.switch2derby");
69       if(JConfig.queryConfiguration("db.protocol", "jdbc:derby:").contains("mysql")) {
70         JConfig.setConfiguration("temp.db.switch2derby", "true");
71       }
72       JConfig.kill("temp.db.protocol");
73       JConfig.kill("temp.db.driver");
74       JConfig.kill("temp.db.user");
75       JConfig.kill("temp.db.pass");
7576     } else if (mysqlDB.isSelected()) {
77       if(!JConfig.queryConfiguration("db.protocol", "jdbc:derby:").contains("mysql")) {
78         JConfig.setConfiguration("temp.db.switch2derby", "false");
79       }
7680       String host = mysqlHost.getText();
7781 
7882       String port = mysqlPort.getText();
------
9599       JConfig.setConfiguration("temp.db.pass", new String(mysqlPassword.getPassword()));
96100     }
97101 
102     if(JConfig.queryConfiguration("temp.db.switch2derby") != null) {
103       if(mOui == null) mOui = new OptionUI();
104       mOui.promptWithCheckbox(null, "You will have to shut down JBidwatcher and restart for the database change to take effect.", "JBidwatcher restart required", "prompt.db_change_restart");
105     }
106 
98107     return true;
99108   }
100109 
952 954  
193193       }
194194       JConfig.kill("jbidwatcher.created_db");
195195       return true;
196     } else if(JConfig.queryConfiguration("temp.db.switch2derby", "false").equals("true")) {
197       JConfig.kill("db.protocol");
198       JConfig.kill("db.driver");
199       JConfig.kill("db.user");
200       JConfig.kill("db.pass");
196201     }
197202     return false;
198203   }