Reputation: 560
I am creating desktop application with embedded H2 database and I would like to take advantage of the H2 web server so that user can use H2 web console.
I do not have any problem to do so but I would like to specify the connection information for the user on the consoles login screen (url, user..) or open the database for user directly.
final Server s = Server.createWebServer();
s.start().openBrowser(s.getURL());
Upvotes: 0
Views: 229
Reputation: 2170
It's not possible out of the box IMHO. The java code you wrote is running on the server side, but selecting in H2 console a connection (could be H2, postgresql, etc...) requires interaction on the client side.
Possible alternatives:
1- You could write a selenium script to open this for you. This is the easiest way forward and you might add it to your java code with cautions (avoid race conditions).
2- You could tweak the file $HOME/.h2.server.properties in order to have only one possible connection, but you would still need to enter the credentials once and have them saved by your browser.
3- Another alternative would be for you to tweak the H2 console itself to give access to the database, but this would be a security hole. I guess this is why it's not possible to do so even by configuration.
Good luck.
Upvotes: 1