Script / Shell username password blank issues

642 views
Skip to first unread message

Peter

unread,
Aug 28, 2013, 1:26:08 PM8/28/13
to h2-da...@googlegroups.com
h2-1.3.173.jar
Windows 7, Powershell and Cmd

I created a H2 database in a java pgm without a username or password. The file opens fine in H2 console (or anything else) by just leaving the username and password fields blank but I cannot get Script or Shell to open it correctly. The issue seems to be how to correctly specify blank user name and password. Are these supported in the Script and Shell command line tools?

For example, when I try to run the following cmd in a Powershell (or cmd) window in the same directory as the h2 db file, I get Wrong user name or password error.

PS F:\> java -cp b:/h2.jar org.h2.tools.Script -url jdbc:h2:file:test-db -script backup/test-db.2013.08.28.sql
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Wrong user name or password [28000-173]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
        at org.h2.message.DbException.get(DbException.java:171)
        at org.h2.message.DbException.get(DbException.java:148)
        at org.h2.message.DbException.get(DbException.java:137)
        at org.h2.engine.Engine.validateUserAndPassword(Engine.java:302)
        at org.h2.engine.Engine.createSessionAndValidate(Engine.java:147)
        at org.h2.engine.Engine.createSession(Engine.java:122)
        at org.h2.engine.Engine.createSession(Engine.java:28)
        at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:313)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:105)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:90)
        at org.h2.Driver.connect(Driver.java:73)
        at java.sql.DriverManager.getConnection(DriverManager.java:579)
        at java.sql.DriverManager.getConnection(DriverManager.java:221)
        at org.h2.tools.Script.execute(Script.java:157)
        at org.h2.tools.Script.execute(Script.java:136)
        at org.h2.tools.Script.runTool(Script.java:104)
        at org.h2.tools.Script.main(Script.java:53)


Using -user "" -password "" does not seem to work either: 

PS F:\> java -cp b:/h2.jar org.h2.tools.Script -url jdbc:h2:file:test-db -user ""-password "" -script backup/test-db.2013.08.28.sql
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Wrong user name or password [28000-173]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
        at org.h2.message.DbException.get(DbException.java:171)
        at org.h2.message.DbException.get(DbException.java:148)
        at org.h2.message.DbException.get(DbException.java:137)
        at org.h2.engine.Engine.validateUserAndPassword(Engine.java:302)
        at org.h2.engine.Engine.createSessionAndValidate(Engine.java:147)
        at org.h2.engine.Engine.createSession(Engine.java:122)
        at org.h2.engine.Engine.createSession(Engine.java:28)
        at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:313)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:105)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:90)
        at org.h2.Driver.connect(Driver.java:73)
        at java.sql.DriverManager.getConnection(DriverManager.java:579)
        at java.sql.DriverManager.getConnection(DriverManager.java:221)
        at org.h2.tools.Script.execute(Script.java:157)
        at org.h2.tools.Script.execute(Script.java:136)
        at org.h2.tools.Script.runTool(Script.java:104)
        at org.h2.tools.Script.main(Script.java:53)

The database file is definitely being found as I get a lock error if I keep it open in Console and try one of the above.
Thanks for the help, Peter

Peter

unread,
Aug 28, 2013, 3:53:23 PM8/28/13
to h2-da...@googlegroups.com
The required -user argument is: -user '""', that is single quotes surrounding the empty double quotes. No -password argument is required.

PS F:\> java -cp b:/h2.jar org.h2.tools.Script -url jdbc:h2:file:junk -user '""'  -script backup/junk.sql

or

PS F:\> java -cp b:/h2.jar org.h2.tools.Script -url jdbc:h2:file:junk -user '""'  -script backup/junk.zip -options compression zip

if you want it zipped

Thomas Mueller

unread,
Sep 5, 2013, 12:40:56 PM9/5/13
to h2-da...@googlegroups.com
Hi,

I believe the correct way to specify an empty user name is 

java ... -user ""

(that means, without the single quotes). If you use '""' then the user name consists of two double quotes. At least that's what I get.

Regards,
Thomas
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages