I find the documentation about system properties rather confusing...
It seems that there are 2 kinds of properties
1) Ones read from jvm's system properties (SYSTEM PROPERTIES)
Those you can set when starting jvm using -Dname=value notation
They are defined in org.h2.constant.SysProperties
At this moment there seems to be 80 of them.
78 of them are all uppercase.
2 are in camel case (lobCloseBetweenReads, runFinalize)
But when defined as system property they have to be expressed in camel-case
pheew...
But that's not all.
There exists 3 more properties that are for some reason expressed with
static getter methods instead of constants
getCollatorCacheSize(), getMaxQueryTimeout(), getScriptDirectory()
However you set them the same way as the previously mentioned properties.
And then there is the most fundamental property of them all h2.baseDir
which does not have a constant at all
but is only mentioned in the examples.
This can be set using a system property but also in the connection url.
The only way I have come up with to read this property is
System.getProperty("h2.baseDir");
Since there is only 1 System / JVM it follows that there can be only one
baseDir.
So what on earth happens if two or more connections are active and have
different baseDirs?
It seems somehow the property is null.
It seems that the most important property baseDir can not be read from
anywhere reliably?!?
Of course there must be some way because h2 needs it in order to operate.
2) properties read from url or set in sql (CONNECTION PROPERTIES)
There are 33 of these and in most of them the criteria why a property is
set in the connection seems quite arbitrary.
Examples:
- COMPRESS_LOB
Why would I want to change the compression algorithm of lobs everytime I
connect to db.
I admit that sometimes this could be handy, if I know for example that
only this lob is very big so I compress only that.
But most of the time decisions like this are made per the database.
But I can not set this as system property.
- DATABASE_EVENT_LISTENER
Definately something I would like to set when staring the database not
when I connect to it.
- DB_CLOSE_DELAY
Again the same as above
And so on...
Also many of the connection properties I would like to protect so that
no user could change the databases behaviour.
I do understand that h2 was designed to be an embedded database.
But it also advertises being able to serve as a database server.
So we should try to rethink the properties so that they work for both
userbases.
All properties should be system properties.
Some of them can be connection properties.
When starting the system one could (somehow) disable connection
properties based on his preference.
Now I can disable changing the baseDir by setting command line parameter
-ifExists
But that seems ad hoc and it isn't even enough. I would like to restrict
the database to one specific folder without reference to existence.
In case connection property is allowed then should it be only valid for
that connection or is it a way to give commands to the whole server
instance (other connections)?
I think this is also an important distinction that should be made.
If it is valid for the whole server instance then it is a system
property, only set within a connection.
Maybe the first step could be that we could have commandline parameters
that would disallow any changes made through connections (eg. -restricted)
And all connection properties that make sense as system properties would
be available as system properties.
So if I start the process with -restricted -baseDir /foo
Then the only way to connect to the database would be with a url like
jdbc:h2:tcp://server/dbname;real_conn_props_like_user_and_password
Currently the centralized management of h2 seems impossible.
- rami
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.