Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello gyus!
I am using sqldump to take backup of my sql database using code bellow:
where final path = destination path and name
C#
String cmd = "mysqldump -u"+databaseUserName+" "+"-p"+databasePassword
                       +" "+databaseName+" "+"-r"+finalPath+".sql";
               Process run = Runtime.getRuntime().exec(cmd);
               int complete = run.waitFor();
               if (complete == 0)//return zero if sucess full
               {
                   //if process is sucess full
               
                
                         statuse_lbl.setText("Opration Successfull...!");
               } else {
                    String completeTime =dateFormat.format(calender.getTime());
                    //if process is not sucessfull
                     do something 
                              
                       
               }


Now problem is that when i take backup on partition C:\ or E:\ it is successful, But when i try to take backup on further directory i-e C:\backup or C:\someFolder or E:\someFolder Then it fails.

Please help me to solve this problem.
Thanks
Posted
Updated 23-Jan-11 21:40pm
v2
Comments
Estys 24-Jan-11 3:41am    
Are you sure your pathname is valid?
THEASCII 24-Jan-11 6:09am    
yes path Name is valid
THEASCII 24-Jan-11 6:12am    
actually i get the path name by a file chooser from the user( i am using netbeans)
Richard MacCutchan 24-Jan-11 4:50am    
What fails? Do you get an error message or an exception, and if so from which application, yours or the database engine?
THEASCII 24-Jan-11 6:10am    
the process of creation backup fails i-e no backup is created and i think it is from database Engine!

What type of error u are getting please mention.

Do one thing put all that block of code in try...catch block and see the error
 
Share this answer
 
Have you tried to print out the command-String and see whether it runs if you just paste it in a console and start it? My guess would be that some chars (eg. "\") might have to be escaped on the console...

Cheers, Arndt
 
Share this answer
 
Comments
THEASCII 4-Mar-11 9:07am    
Thanks bro! i have solved this problem. but it was not the case.anyway thanks for your kind info!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900