Starting Derby Programmatically

北慕城南 提交于 2019-12-01 05:28:39
Bill

This is a embedded database, which means I am taking this from one machine to another and willing to start just by double clicking on the jar file,

In the case of derby, an embedded database means that the database runs in the JVM and writes to the file system. Which implies that you can move the jar file around like you want, but if you use an embedded database, then each machine that you run the program on will have its own separate database, and one and only one JVM can use that database at a time. Is that what you want?

If so, the problem is the URL that the program uses. "jdbc:derby://localhost:1527/contact;create=true" is a URL that tells DriverManager to connect to a remote database. It doesn't matter that program loads the embedded driver first.

An embedded URL in Derby looks something like this. jdbc:derby:bar;create=true which will use an embedded database in the bar directory off of the Derby system home or current working directory. For more information on embedded urls, see here connecting to a file-based derby database.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!