我在jsp里使用:
    Runtime rt = Runtime.getRuntime(); 
   Process proc = rt.exec("exp scott/tiger file = c:\mybak.dmp");代码备份数据库,文件生成了,但是大小到2048字节就不动了,要等很久或者吧tomcat停止,文件才正式生成。不知道是什么原因,我在后面加了下面的代码:
         try {
             proc.waitFor();
             } 
        catch (InterruptedException e) {
             e.printStackTrace();
           }
还是一样不行,请问高手怎么回事啊?

解决方案 »

  1.   

    换个跟目录
    把跟目录放到tomcat的盘
      

  2.   

    不会呀,我以前也是这样的,但是把目录换了个就可以了,比如我tomcat在D:盘,我就把备份直接写到D:盘
    而且你是不是应该这样调用:
       String command = "cmd.exe /C exp 用户名/密码@数据库 file='"+fname+"'";
          try
          {
            Process child = Runtime.getRuntime().exec(command);
          }
          catch (IOException e)
          {
            e.printStackTrace();
          }
      

  3.   

    在网上搜了下,加入下面代码好了:
    boolean shouldClose=false;
            try {
                InputStreamReader isr = new InputStreamReader(proc.getErrorStream());
                BufferedReader br = new BufferedReader(isr);
                String line = null;
                while ((line = br.readLine()) != null){
                    if(line.indexOf("错误")!=-1){
                        shouldClose=true;
                        break;
                    }
                }
                //System.out.println(line);
            } 
            catch (IOException ioe) {
                shouldClose=true;
            }
            if(shouldClose)
                proc.destroy();