Logo Search packages:      
Sourcecode: mysql-connector-java version File versions  Download package

void com::mysql::jdbc::util::ServerController::stop ( boolean  forceIfNecessary  )  throws IOException [inline]

Stops the server (if started)

Parameters:
forceIfNecessary use forceStop if mysqladmin doesn't shut the server down
Exceptions:
IOException if an error occurs while stopping the server

Definition at line 164 of file ServerController.java.

References BASEDIR_KEY, DEFAULTS_FILE_KEY, forceStop(), getServerProps(), and serverProcess.

Referenced by testsuite::simple::ServerControllerTest::testServerController().

                                                                    {
            if (this.serverProcess != null) {

                  String basedir = getServerProps().getProperty(BASEDIR_KEY);

                  StringBuffer pathBuf = new StringBuffer(basedir);

                  if (!basedir.endsWith(File.separator)) {
                        pathBuf.append(File.separator);
                  }

                  String defaultsFilePath = getServerProps().getProperty(
                              DEFAULTS_FILE_KEY);

                  pathBuf.append("bin");
                  pathBuf.append(File.separator);
                  pathBuf.append("mysqladmin shutdown");

                  System.out.println(pathBuf.toString());

                  Process mysqladmin = Runtime.getRuntime().exec(pathBuf.toString());

                  int exitStatus = -1;

                  try {
                        exitStatus = mysqladmin.waitFor();
                  } catch (InterruptedException ie) {
                        ; // ignore
                  }

                  //
                  // Terminate the process if mysqladmin couldn't
                  // do it, and the user requested a force stop.
                  //
                  if (exitStatus != 0 && forceIfNecessary) {
                        forceStop();
                  }
            }
      }


Generated by  Doxygen 1.6.0   Back to index