• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to build a derby database in a jar  RSS feed

 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please share your thoughts on how to bundle a derby database in a jar

I have struck a block in doing so.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have to... Derby comes in a jar as it is.

But if you want to pack the actual database files in a jar, that is possible to. Just follow this "recipe".

1. Populates your database. Remember to do a proper shutdown of this database. This ensures that the database is checkpointed (see the Derby Reference Manual under the shutdown=true url attribute).
2. Pack the database files and your application in one jar file. The Derby property derby.storage.tempDirectory needs to be set, and the application need to do the above described shutdown when it is exited. Access the database with the url jdbc:derby:classpath:<path to database>.
3. Ship your combined application/database jar file together with derby.jar and there you go.

But this is a READ ONLY database, since you can not write to a jar-file.

If you want to have a base lined database, do as above but make sure that you copy the files to a new, writeable, location.
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response.

Can you ellaborate further on how to make a writeable database.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashwin Sridhar wrote:Thanks for your response.

Can you ellaborate further on how to make a writeable database.


You have all the information you need in the manual.

http://db.apache.org/derby/docs/dev/devguide/cdevdeploy15325.html

http://db.apache.org/derby/docs/dev/devguide/cdevdvlp21955.html

Full devguide at http://db.apache.org/derby/docs/dev/devguide

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!