db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stanley Bradbury <Stan.Bradb...@gmail.com>
Subject Re: Embedding Apache Derby in Tomcat and creating an iBATIS JPetStore Demo
Date Fri, 21 Jul 2006 18:02:08 GMT
Stevo wrote:
> Excellent demonstration and now that I know how to do embed derby into 
> Tomcat, I have many uses for it.
> Some notes from my environment.
> Tomcat 5.5.17   in my home directory
> Ubuntu Linux 6.06
> Java 1.5 (Sun)
> I had to fully qualify the url to the database:
> <!-- Global Datasource for Derby JPetStoreDB database -->
>         <Resource name="jdbc/JPetStoreDB"
>              type="javax.sql.DataSource"  auth="Container"
>              description="Derby database for JPetStoreApp"
>              maxActive="100" maxIdle="30" maxWait="10000"
>              username="" password=""              
> driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
> url="jdbc:derby:*/home/ouz/apache-tomcat-5.5.17/Databases/JPetStoreDB*"/>
> After changing the database url I had to restart Tomcat to have it be 
> recognized.
> Deploying the application required a relative directory change on the 
> URLs: (absolute path might have worked as well)
>     Context Path (optional):   /JPetStoreApp
>      XML Configuration file URL:   *../work/JPetStoreAppGbl.xml*
>            WAR or Directory URL:   *../work/JPetStoreApp.war*
> -Steve
I'm glad the article was useful.  Regarding the use of an absolute or 
relative path in the datasource URL; An absolute path will, of course, 
always work.  Relative paths are useful because they are (or can be) 
installation independent.  I assume, however, you ran into problems with 
the database not being found and that is the risk of using relative paths. 

The relative path approach shown in the iBatis paper is not 
deterministic but rather dependent on the default directory of the JVM.  
This ends up being the setting for derby.system.home and all relative 
database path references are 'relative' to derby.system.home.  You might 
want to explicitly set the value of derby.system.home as a JVM argument 
that is defined when Tomcat starts the JVM then you can use a relative 
path in the datasource URLs.  Of course, absolute paths work too but I 
thought this might be of help.

View raw message