使用Java代码关闭Mysql服务器的方法Java代码如下:package com.jy.pub;import java.io.IOException;import com.jy.base.BaseAction;import com.jy.
Java代码如下:
package com.jy.pub;
import java.io.IOException;
import com.jy.base.BaseAction;
import com.jy.util.StringUtil;
public class Startmysql extends BaseAction{
private static Startmysql instance =null ;
private Startmysql(){
}
public static Startmysql getInstance(){
if(instance == null){
logger.info("创建instance...");
instance = new Startmysql();
}
return instance ;
}
public void stop(){
try {
logger.info("关闭mysql服务...");
Runtime.getRuntime().exec("cmd /c start net stop mysql");
logger.info("关闭mysql服务成功...");
} catch (IOException e) {
logger.info("关闭mysql服务失败...");
e.printStackTrace();
}
}
public void backup(){
try {
logger.info("备份数据库...");
String path = new StringUtil().getWEBRoot()+"bat/backup.bat";
Runtime.getRuntime().exec("cmd /c "+path);
logger.info("备份数据库成功...");
} catch (IOException e) {
logger.info("备份数据库失败...");
e.printStackTrace();
}
}
public static void main(String args[]) throws IOException{
Startmysql.getInstance().start();
//Startmysql.getInstance().stop();
}
}
--结束END--
本文标题: 用代码怎么关闭mysql服务器
本文链接: https://lsjlt.com/news/114103.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0