Derby embedded database 'APPDATA' folder not found, Trying to create OS X application .app

被刻印的时光 ゝ 提交于 2019-11-29 08:43:53
Bryan Pendleton

The JDBC Connection URL jdbc:derby:APPDATA says to look for the folder named APPDATA in the current working directory (CWD) of your application.

You need to figure out what your CWD is when your app is launched, perhaps by looking at the answers to this question: Getting the Current Working Directory in Java

Then either

  1. arrange to make your CWD be the place where APPDATA is stored, or
  2. allow the user to tell your app where APPDATA is stored and put that in your JDBC Connection URL.
Ruturaj Patil

As mentioned in my answer here,
In Mac OSX app, location of current working directory of jar can be obtained using

System.getProperty("java.library.path")

Therefore, for connection string, use:

String pwd = System.getProperty("java.library.path");
connect = DriverManager.getConnection("jdbc:derby:"+pwd+"/APPDATA", "#####", "#############");



Since I don't have access to Mac right now, just verify whether value of pwd ends with '/'. If yes append "APPDATA" instead of "/APPDATA".
Hope this helps!

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