Wrong user name or password [28000-202] when trying to start/stop H2 in server mode from the shell - h2

I upgraded recently to the new Version 2.0.202 (2021-11-25) of H2.
I have a shell script, which I wrote while using the Version 1.4.200 (14.10.2019 ?), in which I stop and start a H2-Server using:
java -cp h2*.jar org.h2.tools.Server -tcpPort 9092 -tcpShutdown tcp://11.333.444.111:9092 -tcpShutdownForce </dev/null &>/dev/null &>>$WORKING_DIR/logs/h2_servers.log
After the upgrade I am getting a wrong username or password Exception:
Exception in thread "main"
org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Falscher
Benutzername oder Passwort Wrong user name or password [28000-202]
In the .h2.server.properties I have no username or password set.
Is this an issue?
If not what for user name and password to use and where are they set?

You need to specify the same password when you start a TCP server and when you stop it with additional
-tcpPassword some_password
arguments in both commands.
If your server is configured to accept remote connections, you need to choose a some secure password.

This is a bug.
In the earlier versions it was possible to start and stop a H2-Server without providing a value for -tcpPassword.
Using Version 2.0.202 (2021-11-25) it's possible, as with older versions, to start a H2-Server without providing a value for -tcpPassword like so:
java -cp h2*.jar org.h2.tools.Server -tcp -tcpAllowOthers -tcpPort 9092 -web -webPort 8082
The problem is to stop the H2-Server. Using older versions it was possible to do it so:
java -cp h2*.jar org.h2.tools.Server -tcpPort 9092 -tcpShutdown tcp://xx.xxx.xxx.xxx:9092 -tcpShutdownForce
In the Version 2.0.202 I get:
java -cp h2*.jar org.h2.tools.Server -tcpPort 9092 -tcpShutdown tcp://xx.xxx.xxx.xxx:9092 -tcpShutdownForce
Shutting down TCP Server at tcp://xx.xxx.xxx.xxx:9092
Exception in thread "main" org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException:
Wrong user name or password [28000-202]
Which password to provide as I didn't use any?
I opened an issue.

Related

What is the default H2 console Administration password

I'm trying to figure out what is de default administration password. i've tried to add webAdminPassword=pass in .h2.server.properties but is not working
try this,
The answer is -user "".
else try,
name = "sa"
password = ""
In case you got stuck with the default non-blank user when running the client, the full set of parameters will get you past that:
java -cp \h2.jar org.h2.tools.Shell -url "jdbc:h2:file:" -driver "org.h2.Driver" -user "" -password ""
Please go through the below link for more info,
https://www.ge.com/digital/documentation/meridium/APMConnect/V4302_UDLP210/Content/ChangeH2ConsolePassword.htm
There is no default in H2 itself. If you have a system tray icon of H2 Console, you can open the console from its context menu and you will be able to access these features without a password in the opened window.
In all other cases you need to set up the password explicitly. You can add it to the configuration file .h2.server.properties in the home directory of your user with webAdminPassword=some_password (don't forget to restart the console) or you can pass it in the command line java -cp h2-1.4.200.jar org.h2.tools.Server -web -webAdminPassword some_password … and such password will be used instead of password from the configuration file.
Your question does not describe how and where the H2 Console was started. If it was started on another system by another user, you need to edit the configuration file on that system in the profile of that user. If another password was passed in the startup parameters, the configuration file has no effect and you need to figure out what was passed to it.
With spring-boot you define the following variable in application properties: spring.h2.console.settings.web-admin-password. For standalone h2 console, you would use the solution posted by Evgenij Ryazanov.

H2 some confusions and clarifications on URL user passwords etc.,

A few clarifications on different URL types
Embedded connection vs server mode
I have an app running in grails that runs on a server. On the same server I have H2 running.
Does this mean the grails app can talk to the H2 db ? (no external connections)
or
The grails app cannot talk to the db ?
======================================================
Setting user and password
What is the difference between
URL="jdbc:h2:tcp://localhost/mem:test;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;"
java -cp h2*.jar org.h2.tools.Shell -url "${URL};INIT=RUNSCRIPT FROM 'putdata.sql'" -user cool -password columbus -sql "SET #ignore_me = 0;"
vs
URL=jdbc:h2:file:~/sample;USER=sa;PASSWORD=123
Essentially setting password in java command line vs password in the URL.
Am I understanding this all wrong ?

Cannot create a JDBC Resource or Connection Pool

I have recently installed GlassFish v4.1.1 on my computer (Windows 8.1).
When I execute my GlassFish Server and enter in the administration webpage(http://localhost:4848/common/index.jsf from the NetBeans project), I obtain:
When, when I press the button "Create New JDBC Resource" or "Create new JDBC Connection Pool" the following error appears:
I really do not understand what is going on. Could you help me please ?
Thank you so much for your help.
I'm facing the same issue and I found a solution: instead of creating the connection pool using my IDE (Netbeans), I used the command line:
My DB username is root with an empty password and I'm working on my localhost.
My table is named tmpDb and the pool myPool3.
Here is the used command
$> cd "c:\Program Files\glassfish4\bin"
$> asadmin create-jdbc-connection-pool --restype javax.sql.DataSource --datasourceclassname org.apache.derby.jdbc.ClientDataSource --validationmethod table --validationtable DUAL --property User=root:Password="":ServerName=localhost:tmpDb --ping true myPool3
Does this work for you?

Connecting to Oracle WebLogic Server Instance (Admin Server)

I have just started playing around with Oracle Weblogic. I am trying to do some scripting using WLST , a commandline tool. I have a test environment set up which has Weblogic 10.3 and Linux 2.6.18 on it. I have managed to log into wlst in the offline/interactive mode.
I now want to connect to the AdminServer in my domain. I am having issues doing so.
Following is the command that I am using:
wls:/offline> connect('username','password','localhost:7002')
Once the command is fired it just shows the cursor blinking and the operation does not timeout.
Using the console I have verified the state of the AdminServer , the user defined in security realm and the listen port of the server.
I am wondering why the above command did not work.
On the other hand I created a test managed server using the administration console and successfully made a connection through wlst using the same command.
Am I missing something ?
Thanks !!
I see two things.
On a default installation, port 7002 is a ssl port. It might not be configured and to use it you should specify the t3s protocol, instead of using default t3.
Also, the server is not listening on localhost. That server has an IP address, and chances are the admin server bound to it. It is not listening to 127.0.0.1.
To tell, issue this command (Linux):
#Linux
netstat -plan | grep 7001.*LISTEN
REM Windows
netstat -a -p tcp -n -o | findstr /R 7001.*LISTENING
You will see something like this (Linux):
tcp 0 0 ::ffff:192.168.1.11:7001 :::* LISTEN 20993/java
You can use the IP address, but might as well use the fully qualified name given by:
nslookup 192.168.1.11
Try again connecting :
connect('username','password','t3://myserver-fqdn.example.com:7001')
Or if SSL is configured, this should work:
connect('username','password','t3s://myserver-fqdn.example.com:7002')
Mohan there could be missing in /etc/hosts file. Please check that other reason could be firewall on the Linux box would making issue.
can you show your connect command for managed server? That may hint us to identify issue.
Did you tried with the 1p addresss as well with t3:// protocol?

How to connect to the H2 database used in Gerrit

I tried the following command, but it failed.
ssh -p 24198 my_server gerrit gsql
That is the correct command. What error did you get? Was Gerrit up and running? It must be up and running to connect over ssh. See http://gerrit-documentation.googlecode.com/svn/Documentation/2.4/cmd-gsql.html
If Gerrit is not up and running, you can use java -jar gerrit.war gsql -d <SITE_PATH> - see http://gerrit-documentation.googlecode.com/svn/Documentation/2.4/pgm-gsql.html

Resources