From b59b56fc8cc3fdf0220608bb0a1baff23d95a970 Mon Sep 17 00:00:00 2001 From: Shireesh Anjal Date: Thu, 18 Aug 2011 21:35:26 +0530 Subject: Modified to use DBUtil#shutdownDerby --- .../management/gateway/utils/PasswordManager.java | 48 +--------------------- 1 file changed, 1 insertion(+), 47 deletions(-) (limited to 'src') diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java index df3aeff7..a3593d0c 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java @@ -49,7 +49,7 @@ public class PasswordManager { System.out.println("Password for user [" + username + "] reset successsfully to default value of [" + CoreConstants.DEFAULT_PASSWORD + "]." + CoreConstants.NEWLINE); - shutdownDerby(); + DBUtil.shutdownDerby(); } catch (Exception e) { System.err.println(CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Password reset for user [" + username + "] failed! " + CoreConstants.NEWLINE @@ -59,52 +59,6 @@ public class PasswordManager { } } - private void shutdownDerby() { - try { - // the shutdown=true attribute shuts down Derby - DriverManager.getConnection("jdbc:derby:;shutdown=true"); - - // To shut down a specific database only, but keep the - // engine running (for example for connecting to other - // databases), specify a database in the connection URL: - //DriverManager.getConnection("jdbc:derby:" + dbName + ";shutdown=true"); - } catch (SQLException se) { - if (((se.getErrorCode() == 50000) && ("XJ015".equals(se.getSQLState())))) { - // we got the expected exception - System.out.println("Derby shut down normally"); - // Note that for single database shutdown, the expected - // SQL state is "08006", and the error code is 45000. - } else { - // if the error code or SQLState is different, we have - // an unexpected exception (shutdown failed) - System.err.println("Derby did not shut down normally"); - printSQLException(se); - } - } - } - - /** - * Prints details of an SQLException chain to System.err. - * Details included are SQL State, Error code, Exception message. - * - * @param e the SQLException from which to print details. - */ - private void printSQLException(SQLException e) - { - // Unwraps the entire exception chain to unveil the real cause of the - // Exception. - while (e != null) - { - System.err.println("\n----- SQLException -----"); - System.err.println(" SQL State: " + e.getSQLState()); - System.err.println(" Error Code: " + e.getErrorCode()); - System.err.println(" Message: " + e.getMessage()); - // for stack traces, refer to derby.log or uncomment this: - //e.printStackTrace(System.err); - e = e.getNextException(); - } - } - private ReflectionSaltSource createSaltSource() { ReflectionSaltSource saltSource = new ReflectionSaltSource(); saltSource.setUserPropertyToUse("username"); -- cgit