简体   繁体   English

从Java代码还原DB2数据库

[英]Restore DB2 database from Java code

I need to backup and resotre DB2 database from Java code. 我需要从Java代码备份和解析DB2数据库。 I can make backup by executing 我可以通过执行备份

CALL SYSPROC.ADMIN_CMD('BACKUP DATABASE MY_DB ONLINE TO "/tmp" EXCLUDE LOGS WITHOUT PROMPTING')

On the other hand, I have some linux db2 client commands to restore 另一方面,我有一些linux db2客户机命令要还原

db2 connect to MY_DB; 
db2 quiesce db immediate force connections; 
db2 connect reset;
db2 'RESTORE DATABASE MY_DB ONLINE FROM "/tmp" TAKEN AT 20151223185416 WITHOUT PROMPTING';
db2 ROLLFORWARD DATABASE MY_DB TO END OF LOGS ONLINE;

Can I somehow turn it into the stored procedure and call it from java code? 我可以以某种方式将其转换为存储过程并从Java代码中调用它吗?

Thanks 谢谢

It's not possible to perform a database-level recovery operations ( RESTORE or ROLLFORWARD ) while the database is online. 数据库联机时,无法执行数据库级恢复操作( RESTOREROLLFORWARD )。 Thus, you can't be connected to the database and do this. 因此,您将无法连接到数据库并执行此操作。 You can, however, perform tablespace-level recovery operations; 但是,您可以执行表空间级的恢复操作。 you can restore any tablespace (other than SYSCATSPACE ) and perform the rollforward operation. 您可以还原任何表空间( SYSCATSPACE除外)并执行前滚操作。

Keep in mind if you are doing this, you could run into minimum-point-in-time recovery issues – the database catalog can't disagree with the state of a tablespace. 请记住,如果这样做,可能会遇到最小时间点恢复问题-数据库目录不能不同意表空间的状态。

Be aware, though, that the ADMIN_CMD procedure is not compatible with RESTORE , so you won't be able to do this via a JDBC connection to your database. 但是请注意, ADMIN_CMD过程与RESTORE不兼容,因此您将无法通过与数据库的JDBC连接来执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM