1. What you propose would prevent the first process from termination, which is bad.
I don't understand your answer, I would have expected a connection to
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1&AUTO_SERVER=TRUE to behave like
this code (which does not prevent any process to terminate):
Server would be started on first connection and will stop when the JVM
shuts down.
I don't understand your 3rd point: what do lock files have to do with
in-memory databases?
Currently, the auto-server mode works as follows:
- the first application that opens the database writes its ip address
and port into the .lock.db file
- the second application will detect this and connect to this ip
address and port
The auto-server mode is useful if multiple processes use the same
database, even if the database file is on a networked file system.
That means the auto-server mode also supports that multiple computers
access the same database.
An in-memory database doesn't write any files, so the auto-server mode
doesn't currently work with in-memory databases.
As far as I understand your use case, you want multiple processes
*within the same computer* access the same in-memory database. Right?
The only way this is supported currently is starting a TCP server
manually (as documented), and then access the in-memory database
either remotely (using jdbc:h2:tcp://localhost/mem:test) or within the
same process (using either the remote URL, which is slow, or using
jdbc:h2:mem:test).
Regards,
Thomas
-- Noel.
> I checked the documentation and I can't find a place where we explain that.
I'm not sure if you talk about the auto-server mode or the in-memory database.
Auto-server mode:
http://h2database.com/html/features.html#auto_mixed_mode (I will try
to extend the documentation to be more clear, it looks like it's not
easy to do that).
In-memory databases:
http://h2database.com/html/features.html#in_memory_databases "To
access an in-memory database from another process or from another
computer, you need to start a TCP server in the same process as the
in-memory database was created. The other processes then need to
access the database over TCP/IP or SSL/TLS, using a database URL such
as: jdbc:h2:tcp://localhost/mem:db1."
Regards,
Thomas