Moving ".h2.server.properties" file to another folder/installation dir possible?

1,495 views
Skip to first unread message

Ben

unread,
Mar 23, 2013, 4:14:53 AM3/23/13
to h2-da...@googlegroups.com
As the documentation shows the settings file ".h2.server.properties" is stored by default in the users home directory
Under Window in
 
 C:\Documents and Settings\[username].
 
Can I somehow put it into another directory (e.g. the installation directory of H2)?
 
This would mean I have either to pass the new location as cmdline argument to H2
or to setup a (new) enviroment variable like
 
set H2CONFIG=D:\database\H2\.h2.server.properties
 
Among other considerations I need this to have always a portable H2 version on USB Stick at hand.
 
In best case H2 itself should have internally a search order:
 
1.) Users home directoryQ
2.) Own installation directory
 
Thank you
Ben
 

Thomas Mueller

unread,
Mar 23, 2013, 4:22:56 AM3/23/13
to H2 Google Group
Hi,

The directory where the file is stored / loaded is configurable when starting the Server tool with the "-properties" setting. See: http://h2database.com/javadoc/org/h2/tools/Server.html#main_String...

Regards,
Thomas



Ben
 

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ben

unread,
Mar 24, 2013, 2:40:07 AM3/24/13
to h2-da...@googlegroups.com
Ok, thank you.
 
The link you mentioned is for connecting from Java to server.
 
What about passing a properties file at cmdline in h2.bat?
 
I found no tag "-properties" in whole pdf manual.
 
When I make a guess and change the line in h2.bat to
 
@java -cp "h2-1.3.171.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.Console -properties ".\myproperties" %*
 
...then no properties file is created in the folder where h2-1.3.171.jar is located.
Do users have to create this file manually?
 
In general I miss the (default) properties file at all after installation of H2. O.k. by default it should be in
 C:\Documents and Settings\[username]
I guess this is only the directory for old WinXP. For (64bit) Win7 it should be:
 
C:\Users\[username]\.h2.server.properties
 
But I didn't find the default properties file there neither.
 
I would appreciate to have a sample properties file to get information on how to e.g. setup a different port in it.
When I search the pdf manual for "server.properties" I did NOT find any info about syntax.
 
How does it work?
 
Thank you
Ben

Thomas Mueller

unread,
Mar 24, 2013, 4:29:36 AM3/24/13
to H2 Google Group
Hi,

The settings file is only stored if you change a setting, or after you login.

The command line documentation and the Javadocs are not in the PDF. If you find a way to include it in the PDF, then a patch would be welcome.

> I would appreciate to have a sample properties file to get information on how to e.g. setup a different port in it.

I think it's quite easy to figure it out by looking at the properties file, and by reading the documentation.

Regards,
Thomas

marcolopes

unread,
Apr 11, 2013, 12:46:55 AM4/11/13
to h2-da...@googlegroups.com
Hi Thomas,

I'm using H2 1.3.169, and cannot start the server with the "-properties" parameter.

The server won't start (it starts ok without any parameters).

Here is the code:
            server=Server.createWebServer("-properties /foldername");
            server.start();

I took a look at H2 sources, and you just process the folder and add the default file name... everything looks fine to me!

        // set the serverPropertiesDir, because it's used in loadProperties()
        for (int i = 0; args != null && i < args.length; i++) {
            if ("-properties".equals(args[i])) {
                serverPropertiesDir = args[++i];
            }
        }
...
           if ("null".equals(serverPropertiesDir)) {
                return new Properties();
            }
            return SortedProperties.loadProperties(serverPropertiesDir + "/" + Constants.SERVER_PROPERTIES_NAME);

I can't see what i'm doing wrong!!!

Thanks.

Ryan How

unread,
Apr 11, 2013, 1:07:38 AM4/11/13
to h2-da...@googlegroups.com
what happens if you don't put a leading / ? It would appear that it would try and load it from the root if you start with a leading /, and without it, it would try and load from the current working directly.

So I'd try omitting the leading / and making sure the current working directory is set correctly and try it.

Or specify a full path name to the properties folder?

You could always put a break point in and see what is happening internally? If it is not finding the properties file, or finding it, but properties are invalid, or whatever...
--

Thomas Mueller

unread,
Apr 11, 2013, 2:43:34 PM4/11/13
to H2 Google Group
Hi,

server=Server.createWebServer("-properties /foldername");

That's incorrect, you need to use:

server=Server.createWebServer("-properties", "/foldername");

Regards,
Thomas


marcolopes

unread,
Apr 12, 2013, 2:50:17 AM4/12/13
to h2-da...@googlegroups.com
Of course!
                serverPropertiesDir = args[++i];

Thanks!
Reply all
Reply to author
Forward
0 new messages