跨操作系统在JAVA(No.exe)中还原.backup PostgreSQL
我想用JAVA在PostgrSQL中还原一个本地.backup数据库,但我不想使用pg_restore.exe方法,我需要将它用于所有操作系统,如Windows、Linux。。。 我尝试了这个函数,但它不工作,它有.exe跨操作系统在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
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呢?