Default details for a h2Database

I had exactly the same problem once : I could not access to an H2 file-based database. I never specify any user of password for H2 databases. When I had the connection problem "Wrong user name or password", there was already an existing file from a previous run of the application. Removing the existing *.db files solved the problem (I guess it was created with a generated user/password couple, which has changed since).


Is your user name really "-user", and is the password an empty string? You are calling the method DriverManager.getConnection(String url, String user, String password) with the parameters

  • url = "jdbc:h2:~/test"
  • user = "-user"
  • password = "" (empty string)

In case you want the user name and the password be both an empty strings, you have two options:

DriverManager.getConnection("jdbc:h2:~/test", "", "");
DriverManager.getConnection("jdbc:h2:~/test");

Tags:

H2