Is there any way to save embbeded apache derby database files in jar

怎甘沉沦 提交于 2019-12-13 06:52:41

问题


In my project when i clicked the jar file it extracts embedded database files to near it self.

Is there any way to make them stay in the jar file?


回答1:


You can package a read-only Derby database into one of the jar files in your classpath, and access it using a different form of the connection URL. See: http://db.apache.org/derby/docs/10.8/devguide/cdevdvlp24155.html and http://db.apache.org/derby/docs/10.8/devguide/cdevdeploy11201.html#cdevdeploy11201




回答2:


Sure it's possible, you can put your DB image into any JAR's classpath and access it using:

Class.getResourceAsStream()


来源:https://stackoverflow.com/questions/7671026/is-there-any-way-to-save-embbeded-apache-derby-database-files-in-jar

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