# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/matthias/NetBeansProjects/core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: derby/src/org/netbeans/modules/derby/DerbyDatabasesImpl.java --- derby/src/org/netbeans/modules/derby/DerbyDatabasesImpl.java Base (BASE) +++ derby/src/org/netbeans/modules/derby/DerbyDatabasesImpl.java Locally Modified (Based On LOCAL) @@ -386,8 +386,14 @@ if (systemHome.length() <= 0) { // NOI18N return false; } + String username = null; + String password = null; // remove all connections first for (DatabaseConnection conn : findDatabaseConnections(dbname)) { + username = conn.getUser(); + if(username != null) { + password = conn.getPassword(); + } try { ConnectionManager.getDefault().removeConnection(conn); } catch (DatabaseException ex) { @@ -395,6 +401,32 @@ } } + // Try to shutdown the dbserver (see http://db.apache.org/derby/docs/10.7/devguide/tdevdvlp40464.html) + try { + Driver driver = loadDerbyNetDriver(); + try { + if (username != null && username.length() >= 0) { + driver.connect( + String.format("jdbc:derby://localhost:%d/%s;user=%s;password=%s;shutdown=true", + RegisterDerby.getDefault().getPort(), + dbname, + username, + password), + new Properties()); + } else { + driver.connect( + String.format("jdbc:derby://localhost:%d/%s;shutdown=true", + RegisterDerby.getDefault().getPort(), + dbname), + new Properties()); + } + } catch (SQLException e) { + // OK, will always occur + } + } catch (DatabaseException ex) { + Logger.getLogger(DerbyServerNode.class.getName()).log(Level.INFO, ex.getLocalizedMessage(), ex); + } + // remove database from disk File databaseFile = new File(systemHome, dbname); FileObject fo = FileUtil.toFileObject(databaseFile);