Start or stop mysql database using java programming

前端 未结 2 754
野趣味
野趣味 2020-12-11 11:07

I am having multiple mysql databases running on multiple servers.In hsql database we can start the server or stop the server using java programming.I am going to use any dat

相关标签:
2条回答
  • 2020-12-11 11:12

    Try this in windows machine:

    START

    Process process = Runtime.getRuntime().exec("net START MySQL");
    

    STOP

    Process process = Runtime.getRuntime().exec("net STOP MySQL");
    
    0 讨论(0)
  • 2020-12-11 11:24

    If you are using a linux system, you can invoke the database init script using java. They are usually located in /etc/init.d/mysql[d] ond BSD variants it is found in /usr/local/etc/rc.d/. I am not sure how this work in Windows environments.

    You have to ensure that your user which is running the process is allowed to execute this scripts.

    0 讨论(0)
提交回复
热议问题