Of course you can try and load your database in embedded mode from
outside your webapp directory, but personally I think that violates
the concept of a webapp as self-contained single .war file.
Also, server mode allows you to put the database on another server in
future if needed (to decrease load etc)
> --
> You received this message because you are subscribed to the Google Groups "H2 Database" group.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to h2-database...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
>
>
> If I create a web application and create an H2 database from the code,
> as mentioned above, will this work within Tomcat?
Yes, it should work. It works for me.
The problem is the database URL.
What you should *avoid* is use a path relative to the current working
directory such as: jdbc:h2:./test (which is the same as jdbc:h2:test)
then it means "store the database in the current working". This is a
very common error cause, because it depends on how and where you have
started the application (or Tomcat). This is also a problem when using
the server mode, for example: jdbc:h2:tcp://localhost/test.
It's much better to use an absolute path, for example:
jdbc:h2:/data/test (or jdbc:h2:file:/data/test or
jdbc:h2:tcp://localhost//data/test - please note the two "/" after
localhost). Or, if you want, use a path relative to the current user
working directory (jdbc:h2:~/data/test) but then the problem is that
you need to ensure it's always the same user.
> What is the best practice for deployment?
An absolute path is a good idea.
Regards,
Thomas