Hi.
I almost always use H2 in server mode, but I prefer to start the
server in a seperate JVM. That way I run in it in a "pure" server mode
with all clients accessing the server via the TCP/IP protocol. This
way I don't need any application open to still have the database open
and I can connect to it via NetBeans and Squirrel or anything else. It
has the added advantage that I can restart any part of the system
(except the DB server) without affecting other users.
I don't know if this helps. On Windows you can even set H2 as a
background service and on Linux a daemon thread works wonders.
I then use the following code in each application to access the
database:
try {
Class.forName("org.h2.Driver");
conn = DriverManager.getConnection("jdbc:h2:tcp://" +
ipAddress +
"//myappfolder/db/myappdatabasename", userName,
pwdString);
} catch (Exception e) {
Logger.VLog("Error connecting to the database!",
"Error connecting to the database : " + e.toString
() + " (" + ipAddress + ")");
}
ipAddress, userName, pwdString are all Strings.
Logger.VLog is an internal visual logger.
Best regards
Ewald
--
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.