eclipse上通过Java创建Derby数据库出错;没有“service.properties”;文件
我有(java)代码,使用文本文件作为源数据在 derby 数据库中创建和填充表。我目前正在 Win7 上的 eclipse indigo 中运行它,并且运行良好。
我在该程序中有其他代码,根据用户的选择,创建该数据要进入的数据库。我无法让那部分工作。
它使用 'jdbc:derby:x\y;create=true' 作为其连接字符串;它从 DriverManager.getConnection(connectionString,properties) 抛出异常,说“数据库目录 blah\blah\x\y 存在;但是,它不包含预期的 'service.properties' 文件。也许......”和一些在
运行此命令之前,我删除了目录 x 和 y,然后对我的代码所在的 eclipse 项目执行刷新。这些目录当前与我的 eclipse 项目位于同一目录中。 , 目录 x和 y 都已创建,但不是我的数据库。
如果我删除这些目录,请打开命令提示符,将默认值设置为包含 x 的目录,启动 ij,并使用具有与上面给出的相同连接字符串的连接语句。 ,它创建目录和数据库,然后我的程序将按预期填充数据库,没有错误,
我还尝试直接在我的项目所在的工作区目录中创建数据库(即,没有 x 的父目录)。 ,结果相同,所以我不认为这是数据库名称规范中的斜杠。
所以我想知道我可能做错了什么,导致该程序无法创建数据库,就像 ij 中的“connect”语句一样。
I have (java) code that creates and populates tables in a derby database, using text files as source data. I'm currently running it out of eclipse indigo, on Win7, and it works fine.
I have other code in that program that, based on user choice, creates the database into which that data is to go. I can't get that part to work.
It uses 'jdbc:derby:x\y;create=true' as its connection string; it throws an exception from DriverManager.getConnection(connectionString, properties) saying "The database directory blah\blah\x\y exists; however, the it does not contain the expected 'service.properties' file. Perhaps...' and some more irrelevant stuff.
Before I run this, I delete the directories x and y, and then perform a refresh on the eclipse project that my code is in. These directories currently live in the same directory as my eclipse project. After I run my code, directories x and y have both been created, but not my database.
If I delete the directories, open a command prompt, set my default to the directory that is to contain x, start ij, and use the connect statement with the same connection string given above, it creates the directories and the database. THEN my program will populate the database as expected, no errors.
I have also tried creating the database directly in the workspace directory that my project is in (i.e., y without a parent directory of x), with the same result, so I don't think it's the slash in the database name spec.
So I would like to know what I might be doing wrong that prevents that program from creating the database, just like the 'connect' statement in ij will do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了。我已将 derby.system.home 属性设置为数据库名称,而不是合理的(甚至现有的)目录。我还没有弄清楚它到底出了什么问题,但是当我将它设置为硬编码目录时,问题就消失了。
RC
I found it. I had set the derby.system.home property to the database name instead of to a reasonable (or even an existing) directory. I haven't worked out exactly what the problem with it was, but when I set it to a hard-coded directory, the problem disappeared.
rc