DB files location when starting DB in Server mode on Windows

139 views
Skip to first unread message

xonix

unread,
Aug 15, 2011, 1:59:52 PM8/15/11
to H2 Database
Hi,

I've noticed that when starting H2 as windows service, and accessing
DB by url jdbc:h2:tcp://localhost/~/test , then database files are
created in the root of drive C:. Is this correct behaviour? How could
I change db files location, other then absolute path in the jdbc url?


Sincerely yours,
Vladimir

Thomas Mueller

unread,
Aug 18, 2011, 1:18:24 PM8/18/11
to h2-database
Hi,

> I've noticed that when starting H2 as windows service, and accessing
> DB by url jdbc:h2:tcp://localhost/~/test , then database files are
> created in the root of drive C:. Is this correct behaviour?

When running the database as a service, absolute path should be used.
Using ~ in the database URL is problematic in this case, because it
means to use the home directory of the current user. The service
might run without or with the wrong user, so that the database files
might end up in an unexpected place.

> How could
> I change db files location, other then absolute path in the jdbc url?

You could set the baseDir in the configuration. Currently, this is:

wrapper.app.parameter.1=org.h2.tools.Server
wrapper.app.parameter.2=-tcp
wrapper.app.parameter.3=-web

I think the following should work. Could you try that and tell me if
it does? (I don't currently have a Windows machine available):

wrapper.app.parameter.1=org.h2.tools.Server
wrapper.app.parameter.2=-tcp
wrapper.app.parameter.3=-web
wrapper.app.parameter.4=-baseDir
wrapper.app.parameter.5=/data/h2

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages