François <
francois.rappaz@...> writes:
> Hi
> I have java classes and a database within the same jar. Using the connection
> string jdbc:derby:jar:(myfile.jar)mydatabase (now defined at comiled time) all
> works well if I start the application by double-clicking the jar or running the
> jar with java -jar myapp.jar in the directory where myfile.jar and derby.jar
> are. In the manifest of the jar I have a class-path attribute with derby.jar.
>
> Now if I have a shortcut to the jar or in I run the apps from another directory
> the database is lost. For example, running
> java -cp u:\docs ..\myfile.jar ch.my.package.MyMainClass does not resolve the
> problem.
> I could put a properties file with the connection string with the full path to
> the jar file in the connection string, but I would ask if there is another
> solution.
Hi François,
I think you could achieve what you want by using the classpath protocol
instead of the jar protocol. With myfile.jar in the classpath, try this
URL:
jdbc:derby:classpath:mydatabase
Hope this helps,
--
Knut Anders