Package com.mysql.cj.admin
Class ServerController
java.lang.Object
com.mysql.cj.admin.ServerController
public class ServerController
extends java.lang.Object
Controls a MySQL server using Java RunTime methods
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BASEDIR_KEY
Where is the server installed?static java.lang.String
DATADIR_KEY
Where are the databases installed?static java.lang.String
DEFAULTS_FILE_KEY
Where is the config file located?static java.lang.String
EXECUTABLE_NAME_KEY
What is the name of the executable to run?static java.lang.String
EXECUTABLE_PATH_KEY
What is the path to the mysql server executable (if not standard?) -
Constructor Summary
Constructors Constructor Description ServerController(java.lang.String baseDir)
Creates a ServerController with the directory for the MySQL server.ServerController(java.lang.String basedir, java.lang.String datadir)
Creates a server controller for the MySQL server with the given basedir and datadir. -
Method Summary
Modifier and Type Method Description void
forceStop()
Forcefully terminates the server process (if started).java.util.Properties
getServerProps()
Returns the list of properties that will be used to start/control the server.void
setBaseDir(java.lang.String baseDir)
Sets the basedir to use when starting MySQL.void
setDataDir(java.lang.String dataDir)
Sets the data to use when starting MySQL.java.lang.Process
start()
Starts the server, returning a java.lang.Process instance that represents the mysql server.void
stop(boolean forceIfNecessary)
Stops the server (if started)
-
Field Details
-
BASEDIR_KEY
public static final java.lang.String BASEDIR_KEYWhere is the server installed?- See Also:
- Constant Field Values
-
DATADIR_KEY
public static final java.lang.String DATADIR_KEYWhere are the databases installed?- See Also:
- Constant Field Values
-
DEFAULTS_FILE_KEY
public static final java.lang.String DEFAULTS_FILE_KEYWhere is the config file located?- See Also:
- Constant Field Values
-
EXECUTABLE_NAME_KEY
public static final java.lang.String EXECUTABLE_NAME_KEYWhat is the name of the executable to run?- See Also:
- Constant Field Values
-
EXECUTABLE_PATH_KEY
public static final java.lang.String EXECUTABLE_PATH_KEYWhat is the path to the mysql server executable (if not standard?)- See Also:
- Constant Field Values
-
-
Constructor Details
-
ServerController
public ServerController(java.lang.String baseDir)Creates a ServerController with the directory for the MySQL server. The 'datadir' is set to the same directory.- Parameters:
baseDir
- the base directory for the MySQL server.
-
ServerController
public ServerController(java.lang.String basedir, java.lang.String datadir)Creates a server controller for the MySQL server with the given basedir and datadir.- Parameters:
basedir
- the basedir to use when starting MySQL.datadir
- the datadir to use when starting MySQL.
-
-
Method Details
-
setBaseDir
public void setBaseDir(java.lang.String baseDir)Sets the basedir to use when starting MySQL.- Parameters:
baseDir
- the basedir to use when starting MySQL.
-
setDataDir
public void setDataDir(java.lang.String dataDir)Sets the data to use when starting MySQL.- Parameters:
dataDir
- the basedir to use when starting MySQL.
-
start
public java.lang.Process start() throws java.io.IOExceptionStarts the server, returning a java.lang.Process instance that represents the mysql server.- Returns:
- Process a java.lang.Process instance representing the mysql server process.
- Throws:
java.io.IOException
- if an error occurs while starting the mysql server.
-
stop
public void stop(boolean forceIfNecessary) throws java.io.IOExceptionStops the server (if started)- Parameters:
forceIfNecessary
- use forceStop if mysqladmin doesn't shut the server down- Throws:
java.io.IOException
- if an error occurs while stopping the server
-
forceStop
public void forceStop()Forcefully terminates the server process (if started). -
getServerProps
public java.util.Properties getServerProps()Returns the list of properties that will be used to start/control the server.- Returns:
- Properties the list of properties.
-