> I am starting up in mixed mode using:
>
> jdbc.url=jdbc:h2:db/dbname;AUTO_SERVER=TRUE;TRACE_LEVEL_FILE=4
>
> I can not find any log message that tells me where port the server is
> running on.
Why do you want to know the port number? The whole point if the mixed
mode is that you don't _need_ to know the port number.
> The normal web page does not come up either.
You wrote "I am starting up in mixed mode". How did you start up? Did
you open a database connection? Why do you expect a web page should
come up?
Regards,
Thomas
Probably the documentation about the mixed mode is unclear. I will
extend it. Here is what I have so far:
== Mixed Mode ==
"The mixed mode is a combination of the embedded and the remote mode.
The first application that connects to a database does that in
embedded mode, but also starts a server so that other applications
(running in different processes or virtual machines) can concurrently
access the same data. The embedded connections are as fast as if
the database is used in just the embedded mode, while the remote
connections are a bit slower. All clients that want to connect to the
database (no matter if it's an embedded or remote connection) can do
so using the exact same database URL."
Does this answer your questions?
Regards,
Thomas
> I am starting up using a jdbc connection url of: jdbc:h2:db/
> dbname;AUTO_SERVER=TRUE; in process A on server X.
> I want to connect another process in a different JVM to the database
> in process A using JDBC so the URL I need to use is:
>
> jdbc:h2:db/dbname;AUTO_SERVER=TRUE;
>
> or
>
> jdbc:h2:db/dbname
You need to use jdbc:h2:db/dbname;AUTO_SERVER=TRUE
> So, I do not need and can NOT use the URL of the format: "Remote
> using TCP/IP jdbc:h2:tcp://<server>[:<port>]/<databaseName> "
> Is this correct?
That's correct, you don't need to use the TCP/IP address.
> This is why I am asking about the port number. In other words the
> Mixed Mode capability only works on the same server, it does not
> support remote TCP connections?
No, the mixed mode also works if you have multiple computers. But in
that case the database files must be accessible from each computer
(for example using NFS, or Windows file sharing).
> My goal is to run Mixed Mode (embedded) in process A on server X but
> have an application on server Y access the database in process A on
> server X.
> It this possible? I still want to use the embedded feature because of
> the speed.
If server Y can access the files on server X then the "Automatic Mixed
Mode" is fine.
If server Y can't access the files, then you can still use the mixed
mode, however it's no longer automatic. See also
http://www.h2database.com/html/features.html#connection_modes "Mixed
Mode":
"The mixed mode is a combination of the embedded and the remote mode.
The main application connects to a database in embedded mode, but also
starts a server so that other applications (running in different
virtual machines) can concurrently access the same data. The embedded
connections are as fast as if the database is used in just the
embedded mode, while the remote connections are a bit slower."
So you start a server in the process where access the database in embedded mode.
Regards,
Thomas
There is a difference between "Automatic Mixed Mode" and "Mixed Mode".
> This still confuses me, so if server Y cannot access the files on
> Server X, then how would a process on server Y connect to the mixed
> mode database on server X when it does not know the tcp port number?
In that case, don't use ;AUTO_SERVER=true, and pick your own port.
Here an example of what you need to do:
Process 1:
This process uses the database in embedded mode, and starts a server.
Connection embeddedConnection =
DriverManager.getConnection("jdbc:h2:/data/h2/test", "sa", "sa");
String[] args = new String[] {"-tcpPort", "7123", "-tcpAllowOthers"};
Server server = Server.createTcpServer(args).start();
Process 2:
This process can run on another machine.
Connection remoteConnection =
DriverManager.getConnection("jdbc:h2:tcp://servername:7123/data/h2/test",
"sa", "sa");
See also http://www.h2database.com/html/tutorial.html#using_server
Regards,
Thomas
> I'm using a connection pool on Glassfish v3 and I would like to start
> a H2 server
> at the same time of the pool creation.
>
> How to use the parameters "-tcpPort" and "-tpcAllowOthers" in this
> case ?
Sorry, what do you mean with 'how to use the parameters'?
Regards,
Thomas