Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Want to improve this question?
Update the question so it focuses on one problem only by
editing this post
.
Closed
8 years ago
.
after a search on the internet with no result, I turn to you!
I would like to create a java program, that if you click on a button, it makes a backup of a database in postgresql.
I saw that i must use pg_dump but do not understand how to make it work.
can someone please help me?
thank you!
if you want to use an OS command inside a Java program, make this (with vivek answer):
public class Backup{
public static void main(String[] args) throws java.io.IOException, java.lang.InterruptedException {
final String cmd = "pg_dump --format=c --username \"postgres\" db_name > \"D:\\pgBackup\\db_name.backup\"";
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
java.lang.Process p = rt.exec(cmd);