在JAVA(No .exe)中恢复.backup PostgreSQL交叉操作系统

时间:2015-05-21 08:28:20

标签: java postgresql restore postgresql-9.3

我想使用JAVA恢复PostgrSQL中的本地(.backup)数据库,但我不想使用pg_restore.exe方法(我需要它与Windows,Linux等所有操作系统一起使用) 。 我尝试过这个功能,但它没有工作,它有.exe

public static void RestoreWin() throws IOException{
 Runtime r = Runtime.getRuntime();
 Process p;
 //ProcessBuilder pb;
 r = Runtime.getRuntime(); 
 String[] cmd = {
    "C:\\Program Files\\PostgreSQL\\9.3\\bin\\pg_restore.exe",
    "--host", "localhost",
    "--port", "5432",
    "--username", "postgres",
    "--dbname", "db_test",
    "--password","password",
    "--verbose",
    "C:\\db_test.backup"
    };
    p = r.exec(cmd);
}

Java中是否有其他解决方案? 谢谢。

0 个答案:

没有答案