开发者

Is there any embedded database/files backup framework for Java?

开发者 https://www.devze.com 2023-01-26 16:53 出处:网络
开发者_运维百科I\'m trying to find a Java library/framework, which I can add to my WAR and enable regular backup of files and databases (started on my own timer). I don\'t want to use a standalone sol
开发者_运维百科

I'm trying to find a Java library/framework, which I can add to my WAR and enable regular backup of files and databases (started on my own timer). I don't want to use a standalone solution for backup (located/maintained apart from my WAR), mostly because it's bigger maintenance headache.

Do you know any such libraries?


Hmm.. Possible but which database are you using? If you are using JavaDb or Apache Derby you already have all the tools you need. You can make a JDBC call to make backups. Here is the code:

String sqlstmt = "CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE(?)";
CallableStatement cs = conn.prepareCall(sqlstmt); 
cs.setString(1,"D:/dbbackups/");
cs.execute(); 
cs.close();

And for scheduling the backup tasks you can make use of Quartz. It is free, opensource and a good job scheduler. If you use some other DB you can still call the command using the System.exec method from the scheduler task.

0

精彩评论

暂无评论...
验证码 换一张
取 消