java derby restoreFrom什么也不做 [英] java derby restoreFrom does nothing

查看:139
本文介绍了java derby restoreFrom什么也不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的这个论坛(第一篇文章),但我习惯了它上了很多次,找到技巧和一些有用的例子和解决我的问题。

I'm new to this forum (first post) but I used to surf on it a lot of times to find tricks and some useful examples and solutions on my problems.

在发布之前,我已经在网络上搜索关于restoreFromderby数据库命令,我阅读derby管理员,参考指南。

Before posting I have search all over the web about the "restoreFrom" derby database command and I read the derby administrator, the reference guide too.

在我的程序创建,备份和检查整体derby程序,连接,断开服务器和数据库等...但没有办法恢复一些内置程序!

I succesfully use in my program the creation, backup and check intergrity derby procedures, connect, disconnect server and database etc... but no way to restore something with built-in procedure !!!

这里是有问题的代码:有问题?不是因为它不会引发任何错误...

Here is the problematic code : Problematic ? not so much cause it does not throw any error...

try {

    Class.forName("org.apache.derby.jdbc.ClientDriver");
    java.util.Properties props = new java.util.Properties();

    String backup = "." + File.separator + "backup" + File.separator
            + "dbcli";
    System.out.println(backup);

    String nsURL = "jdbc:derby://localhost:1527/dbcli;restoreFrom="
            + backup;
    props.setProperty("user", "root");
    props.setProperty("password", "root");

    dbConnection = DriverManager.getConnection(nsURL, props);
    dbConnection.commit();
    System.out.println("commit");

} catch (SQLException ex) {
    isConnected = false;
    Logger.getLogger(Snapshot.class.getName()).log(Level.SEVERE, null,
            ex);
    System.out.println(isConnected);
} catch (ClassNotFoundException ex) {
    Logger.getLogger(Snapshot.class.getName()).log(Level.SEVERE, null,
            ex);
}

它不返回错误,但数据库不恢复,即使使用完整路径到备份目录...

It returns no error but the database is not restored, even with the full path to backup directory...

我一直在搜索天,任何帮助将是巨大的!

I've been searching for days, any help would be great !!!

最好的问候,谢谢你阅读这个java新手的帖子...: - )

Best Regards, Thank you for reading this java newbie post... :-)

编辑:问题是存在的。文件夹...我

THE PROBLEM WAS THE PRESENCE OF .SVN FOLDERS.... I'M SO STUPID.... :-) THANKS FOR HELP AND LONG LIFE TO STACKOVERFLOW !!!

推荐答案

我有一个很好的帮助同样的问题,我解决了,关闭它首先数据库和恢复它。
例如:

I had the same problem and I solved it, shutting it down first the database and after restoring it. For example:

    String nsURL1 = "jdbc:derby://localhost:1527/dbcli;shutdown=true";
    String nsURL2 = "jdbc:derby://localhost:1527/dbcli;restoreFrom="+ backup;
    props.setProperty("user", "root");
    props.setProperty("password", "root");

    DriverManager.getConnection(nsURL1, props);
    dbConnection = DriverManager.getConnection(nsURL2, props);

并使用try-catch

and using try-catch

这篇关于java derby restoreFrom什么也不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆