Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default username and password for h2 when there's nothing explicit in JDBC?

Tags:

h2

From a program, I created a H2 database without specifying any user or password in the JDBC URL.

Now I'm trying to access that database with the Script tool. The doc says to use -user sa in the default case. That doesn't work, and it still doesn't work if I either add -password sa or remove -user. What am I missing?

/opt/h2/bin java -cp h2-1.3.161.jar org.h2.tools.Script -url jdbc:h2:/data/jug/jas-coref.h2 -user sa -password sa -script /data/jug/ris-start.sql Exception in thread "main" org.h2.jdbc.JdbcSQLException: Wrong user name or password [28000-161] at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) at org.h2.message.DbException.get(DbException.java:169) at org.h2.message.DbException.get(DbException.java:146) at org.h2.message.DbException.get(DbException.java:135) at org.h2.engine.Engine.validateUserAndPassword(Engine.java:301) at org.h2.engine.Engine.createSessionAndValidate(Engine.java:146) at org.h2.engine.Engine.createSession(Engine.java:121) at org.h2.engine.Engine.createSession(Engine.java:28) at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:285) at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110) at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94) at org.h2.Driver.connect(Driver.java:72) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:185) at org.h2.tools.Script.execute(Script.java:152) at org.h2.tools.Script.execute(Script.java:133) at org.h2.tools.Script.runTool(Script.java:101) at org.h2.tools.Script.main(Script.java:51) 
like image 319
bmargulies Avatar asked Jan 01 '12 20:01

bmargulies


People also ask

What is the default username and password for h2?

In the H2 Console, in the JDBC URL field, paste the copied URL. In the User Name field, enter the user name. The default user name is tisadmin. In the Password field, enter the password.

What is JDBC URL in h2 database?

As per documentation, default JDBC connection string is jdbc:h2:~/test. And, for TCP connection jdbc:h2:tcp://localhost/~/test.

How do I access my h2 database?

Access the H2 Console You can access the console at the following URL: http://localhost:8080/h2-console/. You need to enter the JDBC URL, and credentials. To access the test database that the greeter quickstart uses, enter these details: JDBC URL: jdbc:h2:mem:greeter-quickstart;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1.


2 Answers

Well, duh, that didn't take long.

The answer is -user "".

like image 170
bmargulies Avatar answered Sep 17 '22 14:09

bmargulies


This might work:

name = "sa" password = "" 
like image 31
Katayoun Avatar answered Sep 18 '22 14:09

Katayoun