2 Replies Latest reply on Jan 26, 2004 6:48 AM by f_kasper

    HSQLDB: Usage of hardcoded DB user/password at JBOSS shutdow

    janssenuwe

      When introduce a non-empty password in login-config.xml, default.script, hsqlservice-xml, everything works fine, unless JBOSS wants to stop the DB Service.

      Code snippet of
      org.jboss.jdbc.HypersonicDatabase:


      ---------------------------------------------------
      /**
      * We now close the connection clean by calling the
      * serverSocket throught jdbc. The MBeanServer calls this
      * method at closing time ... this gives the db
      * a chance to write out its memory cashe ...
      *
      * @author Peter Fagerlund pf@iprobot.com
      */
      protected void stopService() throws Exception {
      Connection connection;
      Statement statement;
      String cmd = "SHUTDOWN";
      String jdbcDriver = "org.hsqldb.jdbcDriver";
      String dbStrVersion_1_6 = "jdbc:hsqldb:hsql://localhost:" + port;
      String user = "sa";
      String password = "";
      try {
      new org.hsqldb.jdbcDriver();
      Class.forName(jdbcDriver).newInstance();
      connection = DriverManager.getConnection(dbStrVersion_1_6,
      user,
      password);
      statement = connection.createStatement();
      statement.executeQuery(cmd);
      log.info("Database closed clean");
      }
      finally {
      embeddedDBServer = null;
      }
      }


      ---------------------------------------------------

      how can I achieve that a stop time the configured user and password are used?

      Thanks

      Uwe Janssen

      Germany

        • 1. Re: HSQLDB: Usage of hardcoded DB user/password at JBOSS shu
          f_kasper

          Got the same problem. Anyone have a solution? or should i rewrite the mbean to take the password as parameter?

          • 2. Re: HSQLDB: Usage of hardcoded DB user/password at JBOSS shu
            f_kasper

            Now i have recompiled the HypersonicDatabase with the folowing changes:

            i declare 2 global variables:
            String user = "sa";
            String password = "";

            getter and setter function for them:
            /**
            * Important. remember this javadoc, or else the code will not be used in the MBean interface
            * @jmx:managed-attribute
            */
            public String getUser(){ return user;}
            /**
            * @jmx:managed-attribute
            */
            public void setUser(final String name) { this.user=name;}
            //public String getPassword(){ return this.user;}
            /**
            * @jmx:managed-attribute
            */
            public void setPassword(final String pass) { this.password=pass;}

            and removed the local variabels in the function stopService()
            user
            password

            now I can stop the db without a stacktrace and. also change user, password in startDatabaseManager if u use this

            /Kasper