views:

751

answers:

1

Hi GUys, I am using Java and Mysql for a Program, I am Using a Script File in order to restore a Databsae.

Under Java I am Executing a command:under bin: mysql -u root -proot test< c:\test.mysql

It is not running while If I run it under cmd line it will execute properly and restore the database.

Is anybody there who knows.. why it happens.. Whats the problem, why its not running if i run it under Java environment.

EXACT SYNTAX: I m Using Process P= runtime.getRunTime().exec(FilePath)

where FilePath Variable is having value: mysql -u root -proot test< c:\test.mysql

I am Using Windiws environment. while if I run the FilePath in CmdLine, it will give the perfect reesult.

Highly thankful or help.

A: 

I think we need some more information. As long as the paths are set up the same, if it will run from the command line, it should run the same from Runtime.exec(). What errors do you see?

Try setting the commend up in a script so you can echo the paths and the command output to a file to look at later. In UNIX that would look like

 LOGFILE=my.log
 echo $PATH > $LOGFILE
 env >> $LOGFILE
 mysql -u root -proot test< c:\test.mysql >> $LOGFILE 2>&1

It looks like you're using Windows, so I don't know how to set of the command file exactly this way; what's important is to make sure you're sending the error output of the mysql commend to the file.

Charlie Martin
I m Using Process P= runtime.getRunTime().exec(FilePath)where FilePath Variable is having value: mysql -u root -proot test< c:\test.mysqlI am Using Windiws environment.while if I run the FilePath in CmdLine, it will give the perfect reesult.Looking for help.. stucked :-(
Ashok Gupta