Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
跨操作系统在JAVA(No.exe)中还原.backup PostgreSQL_Java_Postgresql_Restore_Postgresql 9.3 - Fatal编程技术网

跨操作系统在JAVA(No.exe)中还原.backup PostgreSQL

跨操作系统在JAVA(No.exe)中还原.backup PostgreSQL,java,postgresql,restore,postgresql-9.3,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.getR

我想用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中还有其他解决方案吗?
谢谢。

恢复自定义格式备份的唯一方法是运行pg_restore。有没有办法通过Java使用Postgres控制台?pg_restore是一个常规操作系统可执行文件,而不是Postgres控制台。您应该能够使用不推荐使用的Runtime.exec或推荐的ProcessBuilderWhy运行它?你想解决的问题是什么?为什么不直接调用pg_restore呢?