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 file in H2 console 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:\DB> java -cp b:/h2.jar org.h2.tools.Script -url jdbc:h2:file:test-db -script backups/test-db.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 "" does not seem to work either and gives a curious feature not supported error
PS F:\DB> java -cp b:/h2.jar org.h2.tools.Script -url jdbc:h2:file:test-db -user "" -script backups/test-db.sql
Creates a SQL script file by extracting the schema and data of a database.
Usage: java org.h2.tools.Script <options>
Options are case sensitive. Supported options are:
[-help] or [-?] Print the list of options
[-url "<url>"] The database URL (jdbc:...)
[-user <user>] The user name (default: sa)
[-password <pwd>] The password
[-script <file>] The target script file name (default: backup.sql)
[-options ...] A list of options (only for embedded H2, see SCRIPT)
[-quiet] Do not print progress information
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Feature not supported: "backups/CS-Quarterly-Active-2013.08.28.sql" [50100-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.util.Tool.throwUnsupportedOption(Tool.java:66)
at org.h2.util.Tool.showUsageAndThrowUnsupportedOption(Tool.java:56)
at org.h2.tools.Script.runTool(Script.java:94)
at org.h2.tools.Script.main(Script.java:53)
Thanks for the help, Peter