1 19 20 package org.netbeans.modules.db; 21 22 import org.netbeans.lib.ddl.DBConnection; 23 import org.netbeans.modules.db.explorer.ConnectionList; 24 import org.netbeans.modules.db.explorer.DatabaseConnection; 25 import org.netbeans.modules.db.explorer.DatabaseNodeChildren; 26 import org.netbeans.modules.db.explorer.nodes.RootNode; 27 import org.netbeans.modules.db.runtime.DatabaseRuntimeManager; 28 import org.netbeans.spi.db.explorer.DatabaseRuntime; 29 import org.openide.ErrorManager; 30 import org.openide.modules.ModuleInstall; 31 32 public class DatabaseModule extends ModuleInstall { 33 34 public void close () { 35 38 DatabaseNodeChildren rootNodeChildren = (DatabaseNodeChildren)RootNode.getInstance().getChildren(); 41 if (rootNodeChildren.getChildrenInitialized()) { 42 DBConnection[] conns = ConnectionList.getDefault().getConnections(); 43 for (int i = 0; i < conns.length; i++) { 44 try { 45 ((DatabaseConnection)conns[i]).disconnect(); 46 } catch (Exception e) { 47 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 49 } 50 } 51 } 52 53 DatabaseRuntime[] runtimes = DatabaseRuntimeManager.getDefault().getRuntimes(); 55 for (int i = 0; i < runtimes.length; i++) { 56 if (runtimes[i].isRunning()) { 57 try { 58 runtimes[i].stop(); 59 } catch (Exception e) { 60 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 62 } 63 } 64 } 65 } 66 } 67 | Popular Tags |