Top Description Fields Constructors Methods
com.mysql.cj.admin

public Class ServerController

extends Object
Class Inheritance
Imports
java.io.File, .IOException, java.util.Iterator, .Properties, com.mysql.cj.Constants, com.mysql.cj.util.StringUtils

Controls a MySQL server using Java RunTime methods

Field Summary

Modifier and TypeField and Description
public static final String
BASEDIR_KEY

Where is the server installed?

public static final String
DATADIR_KEY

Where are the databases installed?

public static final String
DEFAULTS_FILE_KEY

Where is the config file located?

public static final String
EXECUTABLE_NAME_KEY

What is the name of the executable to run?

public static final String
EXECUTABLE_PATH_KEY

What is the path to the mysql server executable (if not standard?)

private Process
serverProcess

The process representing the MySQL server

private Properties
serverProps

The list of properties for this server

Constructor Summary

AccessConstructor and Description
public
ServerController(String
the base directory for the MySQL server.
baseDir
)

Creates a ServerController with the directory for the MySQL server.

public
ServerController(String
the basedir to use when starting MySQL.
basedir
,
String
the datadir to use when starting MySQL.
datadir
)

Creates a server controller for the MySQL server with the given basedir and datadir.

Method Summary

Modifier and TypeMethod and Description
private String

Returns:

String the list of command-line arguments.
buildOptionalCommandLine
()

Builds the list of command-line arguments that will be passed to the mysql server to be started.

public void
forceStop()

Forcefully terminates the server process (if started).

private String

Returns:

String the commandline used to start the mysql server.
getCommandLine
()

Returns the full commandline used to start the mysql server, including and arguments to be passed to the server process.

private String

Returns:

String the path to the server executable.
getFullExecutablePath
()

Returns the fully-qualifed path to the 'mysqld' executable

public synchronized Properties

Returns:

Properties the list of properties.
getServerProps
()

Returns the list of properties that will be used to start/control the server.

private boolean

Returns:

boolean if the property should not be a command-line argument.
isNonCommandLineArgument
(String
property name
propName
)

Returns true if the property does not belong as a command-line argument

private boolean

Returns:

boolean if this ServerController is running on Windows
runningOnWindows
()

Is this ServerController running on a Windows operating system?

public void
setBaseDir(String
the basedir to use when starting MySQL.
baseDir
)

Sets the basedir to use when starting MySQL.

public void
setDataDir(String
the basedir to use when starting MySQL.
dataDir
)

Sets the data to use when starting MySQL.

public Process

Returns:

Process a java.lang.Process instance representing the mysql server process.
start
()

Starts the server, returning a java.lang.Process instance that represents the mysql server.

public void
stop(boolean
use forceStop if mysqladmin doesn't shut the server down
forceIfNecessary
)

Stops the server (if started)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BASEDIR_KEYback to summary
public static final String BASEDIR_KEY

Where is the server installed?

DATADIR_KEYback to summary
public static final String DATADIR_KEY

Where are the databases installed?

DEFAULTS_FILE_KEYback to summary
public static final String DEFAULTS_FILE_KEY

Where is the config file located?

EXECUTABLE_NAME_KEYback to summary
public static final String EXECUTABLE_NAME_KEY

What is the name of the executable to run?

EXECUTABLE_PATH_KEYback to summary
public static final String EXECUTABLE_PATH_KEY

What is the path to the mysql server executable (if not standard?)

serverProcessback to summary
private Process serverProcess

The process representing the MySQL server

serverPropsback to summary
private Properties serverProps

The list of properties for this server

Constructor Detail

ServerControllerback to summary
public ServerController(String baseDir)

Creates a ServerController with the directory for the MySQL server. The 'datadir' is set to the same directory.

Parameters
baseDir:String

the base directory for the MySQL server.

ServerControllerback to summary
public ServerController(String basedir, String datadir)

Creates a server controller for the MySQL server with the given basedir and datadir.

Parameters
basedir:String

the basedir to use when starting MySQL.

datadir:String

the datadir to use when starting MySQL.

Method Detail

buildOptionalCommandLineback to summary
private String buildOptionalCommandLine()

Builds the list of command-line arguments that will be passed to the mysql server to be started.

Returns:String

String the list of command-line arguments.

forceStopback to summary
public void forceStop()

Forcefully terminates the server process (if started).

getCommandLineback to summary
private String getCommandLine()

Returns the full commandline used to start the mysql server, including and arguments to be passed to the server process.

Returns:String

String the commandline used to start the mysql server.

getFullExecutablePathback to summary
private String getFullExecutablePath()

Returns the fully-qualifed path to the 'mysqld' executable

Returns:String

String the path to the server executable.

getServerPropsback to summary
public synchronized Properties getServerProps()

Returns the list of properties that will be used to start/control the server.

Returns:Properties

Properties the list of properties.

isNonCommandLineArgumentback to summary
private boolean isNonCommandLineArgument(String propName)

Returns true if the property does not belong as a command-line argument

Parameters
propName:String

property name

Returns:boolean

boolean if the property should not be a command-line argument.

runningOnWindowsback to summary
private boolean runningOnWindows()

Is this ServerController running on a Windows operating system?

Returns:boolean

boolean if this ServerController is running on Windows

setBaseDirback to summary
public void setBaseDir(String baseDir)

Sets the basedir to use when starting MySQL.

Parameters
baseDir:String

the basedir to use when starting MySQL.

setDataDirback to summary
public void setDataDir(String dataDir)

Sets the data to use when starting MySQL.

Parameters
dataDir:String

the basedir to use when starting MySQL.

startback to summary
public Process start() throws IOException

Starts the server, returning a java.lang.Process instance that represents the mysql server.

Returns:Process

Process a java.lang.Process instance representing the mysql server process.

Exceptions
IOException:
if an error occurs while starting the mysql server.
stopback to summary
public void stop(boolean forceIfNecessary) throws IOException

Stops the server (if started)

Parameters
forceIfNecessary:boolean

use forceStop if mysqladmin doesn't shut the server down

Exceptions
IOException:
if an error occurs while stopping the server