Runtime rt = Runtime.getRuntime();
try
{
Process process = rt.exec("cmd mysql -uroot -p*****<"+fullpath);
//导入数据,成功则设置对应的参数
process.waitFor();
System.out.println("执行数据的导入!"+"mysql -uroot -p123 cms<"+fullpath);
System.out.println("数据导入成功!");

}
总是没有导入数据就直接输出了数据导入成功,为什么?

解决方案 »

  1.   

    试试下面的      Runtime rt = Runtime.getRuntime(); 
    try 

    Process process = rt.exec("cmd /c start /min mysql -uroot -p***** <"+fullpath); 
    //导入数据,成功则设置对应的参数 
    process.waitFor(); 
    System.out.println("执行数据的导入!"+"mysql -uroot -p123 cms <"+fullpath); 
    System.out.println("数据导入成功!"); } 
      

  2.   

    dos命令 应该是: "cmd /c mysql -uroot -p***** <" + fullpath 加上/c 就应该好了
      

  3.   

    cmd /c 或者 cmd /k
      

  4.   

    按照二楼的代码,结果出现了mysql client command,接着这个进程就陷入了死锁状态,没有执行数据导入也没有报错,这是为什么?
      

  5.   

    发现了错误,原来是自己的一个失误,上面的代码本身在jdk5.0下就是可以正常执行的,谢谢大家了