This is a relative path. This works, but you need to make sure it is
always started from the same working directory.
> However, this allows only a single connection.
Actually, multiple connections, but all within the same process and
class loader.
> How do I sepcify the URL in JSP to connect to this database using
> tcp://...etc.
Remote connections:
jdbc:h2:tcp://localhost/~/test
(this is using the user home directory).
> I presume that is the only way to get multiple
> connections to the database.
No, you can also use the mixed mode: use the database in embedded mode
in the web application, start a TCP server in the web application and
connect remotely from the browser or another web application. See
also:
Regards,
Thomas
There is also org.h2.server.web.WebServlet
Regards,
Thomas
> If i have two computers and one computer acting as a server runs the
> tcp server. Can I use the other computer to access the server using
> tcp over the network ?
Yes, however this is not allowed for security reasons. To enable it,
start the server with the command line option -tcpAllowOthers as in:
java ... org.h2.tools.Server -tcp -tcpAllowOthers
or in Java code:
Server server = Server.createTcpServer(
new String[] { "-tcpAllowOthers" }).start();
Regards,
Thomas
> Thanks. One thing, can I use SSL with the TCP allow others mode ?
> Maybe it would become more secure.
Yes, you can do that.
Regards,
Thomas
> When trying to make an SSL connection, h2 needs to create (or modify)
> a keystore in the user's home directory. Since our app runs in
> tomcat, as a user called 'tomcat', h2 was trying to create a keystore
> in the home directory for tomcat, which in my case was a system
> directory on the server with root ownership. Since the keystore could
> not be created, the connection failed, with unhelpful log messages to
> the effect of 'connection could not be established.'
The error message in this case is really bad: H2 just swallows the
real exception. I will change the code so that analyzing such problems
will be much simpler in the next release.
Thanks a lot for your help!
Regards,
Thomas