> my scenario: web application using H2 for demo purposes.
I'm not sure, did you already read the documentation at
http://www.h2database.com/html/tutorial.html#web_applications
> We'd like to embed the H2 Console into the existing web application,
> so it's reachable on the same hostname/port, instead of listening on
> its own HTTP port. Is that possible?
Yes, using WebServlet. It is not documented at the moment, I will do
that in the next release.
== Using the H2 Console Servlet ==
The H2 Console is a standalone application and includes its own web
server, but it can be used as a servlet as well. To do that, include
the the h2 jar file in your application, and add the following
configuration to your web.xml:
<servlet>
<servlet-name>H2Console</servlet-name>
<servlet-class>org.h2.server.web.WebServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>H2Console</servlet-name>
<url-pattern>/console/*</url-pattern>
</servlet-mapping>
For details, see also src/tools/WEB-INF/web.xml.
To create a web application that creates just the H2 Console, run the
following command:
build warConsole
> Also, i'd like to embed the web console in our web application, so we
> can frame it with the styles of our web design.
You will probably have to overwrite the stylesheet.
> how to pre-configure the JDBC URI (only allow connections to the single database)
Hm, that doesn't work well I'm afraid. I'm not sure how to do that
exactly. You would need to have a look at the code. What you can do is
start the standalone H2 Console using a connection:
http://www.h2database.com/javadoc/org/h2/tools/Server.html#r15
(Console.startWebServer(Connection conn)).
> - How to start up H2 Server within a Spring Application Context, or should we use DbStarter in web.xml?
I'm sure you can start the H2 Server from Spring, but I don't know
Spring well enough...
> - How to configure the pooled DataSource (Spring managed) to access the H2 Server
I'm not sure if you need to access the Server... What about just
opening a JDBC connection using the server protocol
(jdbc:h2:tcp://...)?
Regards,
Thomas
> Works fine with the following:
>
> <bean id="org.h2.tools.Server"
> class="org.h2.tools.Server"
> factory-method="createTcpServer"
> init-method="start"
> destroy-method="stop">
> <constructor-arg value="-tcp,-tcpAllowOthers,true,-tcpPort,
> 8043" />
> </bean>
>
> "destroy-method" is important to prevent Exceptions when hot-
> redeployment or restarting server.
Thanks a lot! I will add this information to the documentation.
Regards,
Thomas