I have a JAVA project in which I want to display the MySQL databases. I have written this code:
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();
}
But it gives me this error:
Cannot run program "show": CreateProcess error=2, The system cannot find the file specified
What should be done? thanks...
showwithinmysql, you're executing it as a new command line command.show databasescan be run through JDBC as well. Why do you want to run that as an external process?