I am getting problem on executing the following code:
我在执行以下代码时遇到问题:
Process pr = rt.exec("mysql -uroot -pcdac123 -e \""
+ "use rrrlfdev;load data local infile '"
+ fpath
+ "' into table t_adm_despatch fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n' (dispatchno,dispatchdate,dispatchName, dispatchAddress, fileNo)"
+ "\"");
The same is running fine on windows.
在Windows上运行正常。
1 个解决方案
#1
0
Java needs to know command and arguments separately. You can do 2 things
Java需要分别知道命令和参数。你可以做两件事
1) You can try to use exec(String command, String[] arguments) to provide the cmd and the args seperately
1)您可以尝试使用exec(String命令,String []参数)分别提供cmd和args
2) You can enclose the mysql command and each argument into double quotes.
2)您可以将mysql命令和每个参数括在双引号中。
In your case, error is misplacement of quotes starting. There is no such command like
在您的情况下,错误是错误的引号开始。没有像这样的命令
mysql -uroot -pcdac123 -e \" .....
mysql -uroot -pcdac123 -e \“.....
This is the reason it shows help file. Double quotes should be placed after mysql command, like
这就是它显示帮助文件的原因。双引号应该放在mysql命令之后,比如
mysql \" -uroot -pcdac123 -e .....
mysql \“-uroot -pcdac123 -e .....
Hope this will help
希望这会有所帮助
#1
0
Java needs to know command and arguments separately. You can do 2 things
Java需要分别知道命令和参数。你可以做两件事
1) You can try to use exec(String command, String[] arguments) to provide the cmd and the args seperately
1)您可以尝试使用exec(String命令,String []参数)分别提供cmd和args
2) You can enclose the mysql command and each argument into double quotes.
2)您可以将mysql命令和每个参数括在双引号中。
In your case, error is misplacement of quotes starting. There is no such command like
在您的情况下,错误是错误的引号开始。没有像这样的命令
mysql -uroot -pcdac123 -e \" .....
mysql -uroot -pcdac123 -e \“.....
This is the reason it shows help file. Double quotes should be placed after mysql command, like
这就是它显示帮助文件的原因。双引号应该放在mysql命令之后,比如
mysql \" -uroot -pcdac123 -e .....
mysql \“-uroot -pcdac123 -e .....
Hope this will help
希望这会有所帮助