您好我有一个JAVA项目,我想在其中显示MySQL数据库。 我写这样的代码:从java运行mysql命令
try {
String []command={"mysql -u root -pmanager","show databases"};
Process p= Runtime.getRuntime().exec("mysql -u root -pmanager");
Process p1= Runtime.getRuntime().exec("show databases");
if (p.waitFor()==0){System.out.println("backup done...");}
else{System.out.println("!!!");}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
,但它给我这个错误:
Cannot run program "show": CreateProcess error=2, The system cannot find the file specified
什么,应该怎么办? 感谢...
你没有在'mysql'中执行'show',你正在执行它作为一个新的命令行命令。 –
我该怎么做? – ooo
我不确定,但尝试从mysql进程中获取outpustream并写入该文件。 –