Index: src/org/netbeans/modules/db/explorer/DatabaseConnection.java =================================================================== RCS file: /cvs/db/src/org/netbeans/modules/db/explorer/DatabaseConnection.java,v retrieving revision 1.35 diff -c -b -r1.35 DatabaseConnection.java *** src/org/netbeans/modules/db/explorer/DatabaseConnection.java 30 Mar 2005 07:32:39 -0000 1.35 --- src/org/netbeans/modules/db/explorer/DatabaseConnection.java 6 Apr 2005 22:51:41 -0000 *************** *** 96,102 **** public static final String PROP_DRIVERNAME = "drivername"; //NOI18N public static final String PROP_NAME = "name"; //NOI18N ! private OpenConnectionInterface openConnection; static private final Lookup.Result openConnectionLookupResult; static private Collection openConnectionServices = null; --- 96,102 ---- public static final String PROP_DRIVERNAME = "drivername"; //NOI18N public static final String PROP_NAME = "name"; //NOI18N ! private OpenConnectionInterface openConnection = null; static private final Lookup.Result openConnectionLookupResult; static private Collection openConnectionServices = null; *************** *** 114,120 **** /** Default constructor */ public DatabaseConnection() { propertySupport = new PropertyChangeSupport(this); - openConnection = new OpenConnection(); } /** Advanced constructor --- 114,119 ---- *************** *** 132,137 **** --- 131,154 ---- pwd = password; name = null; name = getName(); + } + + private Collection getOpenConnections() { + if (openConnectionServices == null) { + openConnectionServices = openConnectionLookupResult.allInstances(); + } + return openConnectionServices; + } + + private OpenConnectionInterface getOpenConnection() { + if (openConnection != null) + return openConnection; + + openConnection = new OpenConnection(); + String driver = getDriver(); + if (driver == null) { + return openConnection; + } // For Java Studio Enterprise. Create instanceof OpenConnection try { *************** *** 146,158 **** } catch(Exception ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } ! } ! ! private Collection getOpenConnections() { ! if (openConnectionServices == null) { ! openConnectionServices = openConnectionLookupResult.allInstances(); ! } ! return openConnectionServices; } /** Returns driver URL */ --- 163,169 ---- } catch(Exception ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } ! return openConnection; } /** Returns driver URL */ *************** *** 171,176 **** --- 182,188 ---- String olddrv = drv; drv = driver; propertySupport.firePropertyChange(PROP_DRIVER, olddrv, drv); + openConnection = null; } public String getDriverName() { *************** *** 334,340 **** // For Java Studio Enterprise. ! openConnection.enable(); checkRuntime(); if (drvs.length == 0) { --- 346,352 ---- // For Java Studio Enterprise. ! getOpenConnection().enable(); checkRuntime(); if (drvs.length == 0) { *************** *** 355,361 **** propertySupport.firePropertyChange("connected", null, null); // For Java Studio Enterprise. ! openConnection.disable(); return connection; } catch (SQLException e) { --- 367,373 ---- propertySupport.firePropertyChange("connected", null, null); // For Java Studio Enterprise. ! getOpenConnection().disable(); return connection; } catch (SQLException e) { *************** *** 370,376 **** propertySupport.firePropertyChange("failed", null, null); // For Java Studio Enterprise. ! openConnection.disable(); initSQLException(e); DDLException ddle = new DDLException(message); --- 382,388 ---- propertySupport.firePropertyChange("failed", null, null); // For Java Studio Enterprise. ! getOpenConnection().disable(); initSQLException(e); DDLException ddle = new DDLException(message); *************** *** 382,388 **** propertySupport.firePropertyChange("failed", null, null); // For Java Studio Enterprise. ! openConnection.disable(); DDLException ddle = new DDLException(message); ddle.initCause(exc); --- 394,400 ---- propertySupport.firePropertyChange("failed", null, null); // For Java Studio Enterprise. ! getOpenConnection().disable(); DDLException ddle = new DDLException(message); ddle.initCause(exc); *************** *** 408,420 **** propertySupport.firePropertyChange("connecting", null, null); // For Java Studio Enterprise. ! openConnection.enable(); Connection connection; JDBCDriver[] drvs = JDBCDriverManager.getDefault().getDriver(drv); // For Java Studio Enterprise. ! openConnection.enable(); checkRuntime(); if (drvs.length == 0) { --- 420,432 ---- propertySupport.firePropertyChange("connecting", null, null); // For Java Studio Enterprise. ! getOpenConnection().enable(); Connection connection; JDBCDriver[] drvs = JDBCDriverManager.getDefault().getDriver(drv); // For Java Studio Enterprise. ! getOpenConnection().enable(); checkRuntime(); if (drvs.length == 0) { *************** *** 436,442 **** propertySupport.firePropertyChange("connected", null, null); // For Java Studio Enterprise. ! openConnection.disable(); } catch (SQLException e) { String message = MessageFormat.format(bundle.getString("EXC_CannotEstablishConnection"), new String[] {db, drv, e.getMessage()}); // NOI18N --- 448,454 ---- propertySupport.firePropertyChange("connected", null, null); // For Java Studio Enterprise. ! getOpenConnection().disable(); } catch (SQLException e) { String message = MessageFormat.format(bundle.getString("EXC_CannotEstablishConnection"), new String[] {db, drv, e.getMessage()}); // NOI18N *************** *** 450,456 **** propertySupport.firePropertyChange("failed", null, null); // For Java Studio Enterprise. ! openConnection.disable(); initSQLException(e); DDLException ddle = new DDLException(message); --- 462,468 ---- propertySupport.firePropertyChange("failed", null, null); // For Java Studio Enterprise. ! getOpenConnection().disable(); initSQLException(e); DDLException ddle = new DDLException(message); *************** *** 460,466 **** propertySupport.firePropertyChange("failed", null, null); // For Java Studio Enterprise. ! openConnection.disable(); sendException(exc); } --- 472,478 ---- propertySupport.firePropertyChange("failed", null, null); // For Java Studio Enterprise. ! getOpenConnection().disable(); sendException(exc); }