在java(mysql)代码中占用无限时间(错误)?

时间:2017-07-23 12:17:00

标签: java mysql debugging runtime-error

我的java代码在下面

String file = jFileChooser1.getSelectedFile().toString();
String cmd = "E:/XAMPP/mysql/bin/mysql.exe -u root < C:/Users/Admin/Documents/s.sql";
try {
    Process cmdProcess = Runtime.getRuntime().exec(cmd);
    int processState = cmdProcess.waitFor();
    if (processState == 0) {
        System.out.println("Sucess");
    } else {
        System.out.println("Error");
    }
    this.dispose();
} catch (IOException ex) {
    System.out.println("Error : jewelleryshop.database.UploadDatabase.jFileChooser1ActionPerformed(): " + ex.getMessage());
} catch (InterruptedException ex) {
    Logger.getLogger(UploadDatabase.class.getName()).log(Level.SEVERE, null, ex);
}

Runtime.getRuntime().exec(cmd);程序进入无限等待后执行此代码时。但同样的命令(即E:/XAMPP/mysql/bin/mysql.exe -u root < C:/Users/Admin/Documents/s.sql)当我在CMD中给出它工作正常时。 我如何修改此代码以使其运行良好。

0 个答案:

没有答案