diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-08-18 21:35:26 +0530 |
|---|---|---|
| committer | Shireesh Anjal <shireesh@gluster.com> | 2011-08-18 21:35:26 +0530 |
| commit | b59b56fc8cc3fdf0220608bb0a1baff23d95a970 (patch) | |
| tree | c5cfc96065283e979114600fbd1c0e1de3572b37 | |
| parent | 29f7b12e64f79e1d41065605b5961b82768ab93c (diff) | |
Modified to use DBUtil#shutdownDerby
| -rw-r--r-- | src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java | 48 |
1 files changed, 1 insertions, 47 deletions
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 <code>System.err</code>. - * 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"); |
