以编程方式设置derby.system.home [英] Programmatically setting derby.system.home

查看:150
本文介绍了以编程方式设置derby.system.home的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要将JavaDB(derby)db文件的数据库和日志文件移动到部署目录中。数据库正在应用程序启动目录中工作,因为JavaDB创建了一个具有数据库名称的文件夹(在我的例子中是mydb),但是我想将该目录移动到名为data / creating data / mydb的子目录中。我可以使用connect调用来执行此操作:

Need to move the database and log files of JavaDB (derby) db files into deployment directories. The database is working in the application startup directory as JavaDB creates a folder with the name of the database (in my case mydb), but I want to move that dir into a subdir called data/ creating data/mydb. I can do this with the connect call:

DriverManager.getConnection("jdbc:derby:data/mydb;create=false");

这是有效的。但我想以编程方式明确设置

and this works. But I'd like to programmatically explicitly set the value of

derby.system.home = data /

derby.stream.error.file = log / derby.log

derby.system.home=data/
derby.stream.error.file=log/derby.log

所以我可以这样做:

DriverManager.getConnection("jdbc:derby:mydb;create=false");

并且所有dbs都在该数据/目录中。并且derby日志文件将在logs /中!我似乎无法弄清楚这一点。有人帮吗?有没有办法以编程方式设置这些属性(因为它是嵌入的)?

and all dbs would be in that data/ dir. And the derby log file would be in logs/! I just can't seem to figure this out. Anyone help? Is there a way to set those properties programatically (because it's embedded)?

推荐答案

文档(Derby开发人员指南:设置Derby属性)建议类似:

Properties p = System.getProperties();
p.setProperty("derby.system.home", "C:\databases\sample");

我也见过

/* setting an attribute in a Properties object */
Properties myProps = new Properties();
myProps.put("create", "true");
Connection conn = DriverManager.getConnection("jdbc:derby:sampleDB", myProps);

这篇关于以编程方式设置derby.system.home的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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