db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Embretsen <John.Embret...@Sun.COM>
Subject Re: Including a derby db within the same jar as the application ( was Including a derby database in a Windows executable)
Date Fri, 26 Oct 2007 08:39:21 GMT
David Leader wrote:
> jdbc:derby:jar:(MyApp.jar)MyDB
> That works a treat. (And, obviously, it's not Windows-specific - so I 
> changed the subject again.)

Thats great! I was just preparing an answer to your previous mail, with a 
different solution - so we are all learning here :)

Your solution references the jar file itself, and is particularly useful in 
cases where the database is in a different jar (or zip) than the application 
accessing it. I'm wondering if it might fail in some corner cases (e.g. if the 
working directory of the JVM is different from the directory where MyApp.jar is 
located), but I haven't tried it out.

An alternative solution, which is also described in the Developer's guide (under 
"Accessing databases within a jar file using the classpath"), is to not worry 
about the jar file name but just assume that the database is in the classpath.

The URL could for example look like this:


or (to avoid ambiguity) this:


(The database was added to the application's jar using
"jar uf MyApp.jar myDatabase/" )

> Perhaps an example of this sort might be included in  a future update of 
> the derby developer docs - others might want to package a db in an app.

I just went through the docs and agree that they should include more examples.
Feel free to open a Jira issue for this. I might even do so myself if you don't...


View raw message