I have used h2 db as an embedded database for some java applications in the past but this time I would like to run it as a standalone server (tcp) to which I can connect from another client changing the default user and password
I downloaded h2db, unzipped the zip and I saw in the bin directory the following
h2-1.4.196.jar
h2.bat
h2.sh
h2w.bat
I read the documentation and I found that to start the console as well as the server I can simply execute
./h2.sh -webAllowOthers -web -tcpAllowOthers
with this, I can open the web console, log in with the username=sa and the password="" but I can't find a way to change the default username and password
according to the documentation, it can be done by adding the values in the connection string
jdbc:h2:tcp://localhost/~/test;USER=sa1;PASSWORD=welcome
but when I try to open the connection like from the web console I got an error
Duplicate property "USER" [90066-196] 90066/90066
It looks like the user is defined when the server starts up, also I read that there is one file
.h2.server.properties
on which I could find the server properties but I only saw stuff like this
12=Generic H2 (Embedded)|org.h2.Driver|jdbc\:h2\:~/test|sa
13=Generic H2 (Server)|org.h2.Driver|jdbc\:h2\:tcp\://localhost/~/test|sa
it seems that the username is defined there but no the password, I couldn't find ant option to define the parameter for the server only
Server options
Supported options are:
[-web] Start the web server with the H2 Console
[-webAllowOthers] Allow other computers to connect - see below
[-tcp] Start the TCP server
[-tcpAllowOthers] Allow other computers to connect - see below
[-tcpPort <port>] The port (default: 9092)
[-tcpPassword <pwd>] The password for shutting down a TCP server
[-properties "<dir>"] Server properties (default: ~, disable: null)
[-baseDir <dir>] The base directory for H2 databases (all servers)
I already tried starting the Server and later the Console pointing to the server but still, I can't find how to change the username nor the password
Starting the server
java -cp h2-1.4.196.jar org.h2.tools.Server -web -tcp -webAllowOthers -tcpAllowOthers -tcpPassword welcome
TCP server running at tcp://10.157.196.152:9092 (others can connect)
connecting to the server
./console.sh -url tcp://localhost:9092 -driver org.h2.Driver -user sa -password welcome
My question is:
How can I define the default username/password that is used access to the web console?