This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 135937
Collapse All | Expand All

(-)derby/src/org/netbeans/modules/derby/DerbyDatabasesImpl.java (+32 lines)
Lines 386-393 Link Here
386
        if (systemHome.length() <= 0) { // NOI18N
386
        if (systemHome.length() <= 0) { // NOI18N
387
            return false;
387
            return false;
388
        }
388
        }
389
        String username = null;
390
        String password = null;
389
        // remove all connections first
391
        // remove all connections first
390
        for (DatabaseConnection conn : findDatabaseConnections(dbname)) {
392
        for (DatabaseConnection conn : findDatabaseConnections(dbname)) {
393
            username = conn.getUser();
394
            if(username != null) {
395
                password = conn.getPassword();
396
            }
391
            try {
397
            try {
392
                ConnectionManager.getDefault().removeConnection(conn);
398
                ConnectionManager.getDefault().removeConnection(conn);
393
            } catch (DatabaseException ex) {
399
            } catch (DatabaseException ex) {
Lines 395-400 Link Here
395
            }
401
            }
396
        }
402
        }
397
403
404
        // Try to shutdown the dbserver (see http://db.apache.org/derby/docs/10.7/devguide/tdevdvlp40464.html)
405
        try {
406
            Driver driver = loadDerbyNetDriver();
407
            try {
408
                if (username != null && username.length() >= 0) {
409
                    driver.connect(
410
                            String.format("jdbc:derby://localhost:%d/%s;user=%s;password=%s;shutdown=true",
411
                            RegisterDerby.getDefault().getPort(),
412
                            dbname,
413
                            username,
414
                            password),
415
                            new Properties());
416
                } else {
417
                    driver.connect(
418
                            String.format("jdbc:derby://localhost:%d/%s;shutdown=true",
419
                            RegisterDerby.getDefault().getPort(),
420
                            dbname),
421
                            new Properties());
422
                }
423
            } catch (SQLException e) {
424
                // OK, will always occur
425
            }
426
        } catch (DatabaseException ex) {
427
            Logger.getLogger(DerbyServerNode.class.getName()).log(Level.INFO, ex.getLocalizedMessage(), ex);
428
        }
429
        
398
        // remove database from disk
430
        // remove database from disk
399
        File databaseFile = new File(systemHome, dbname);
431
        File databaseFile = new File(systemHome, dbname);
400
        FileObject fo = FileUtil.toFileObject(databaseFile);
432
        FileObject fo = FileUtil.toFileObject(databaseFile);

Return to bug 135937