I'm trying to do this in an arbitrary folder:
java -cp .;e:\tools\h2\bin\* org.h2.tools.RunScript -url myDBURI -script CreateDatabase.sql
CreateDatabase.sql is in the current folder.
Inside it I have:
runscript from 'classpath:/DropSchemas.sql';
I have also tried
runscript from 'DropSchemas.sql';
runscript from './DropSchemas.sql';
When I do this I get a file not found error fror DropSchemas.sql:
Exception in thread "main" org.h2.jdbc.JdbcSQLException: IO Exception: "java.io. FileNotFoundException: resource /DropSchemas.sql"; "classpath:/DropSchemas.sql"; SQL statement:
runscript from 'classpath:/DropSchemas.sql' [90031-172]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.message.DbException.convertIOException(DbException.java:315)
at org.h2.command.dml.ScriptBase.openInput(ScriptBase.java:168)
at org.h2.command.dml.RunScriptCommand.update(RunScriptCommand.java:45)
at org.h2.command.CommandContainer.update(CommandContainer.java:79)
at org.h2.command.Command.executeUpdate(Command.java:235)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:335)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:151)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: resource /DropSchemas.sql
at org.h2.store.fs.FilePathDisk.newInputStream(FilePathDisk.java:298)
at org.h2.store.fs.FileUtils.newInputStream(FileUtils.java:206)
at org.h2.command.dml.ScriptBase.openInput(ScriptBase.java:166)
... 6 more
at org.h2.engine.SessionRemote.done(SessionRemote.java:579)
at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:186)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:180)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:155)
at org.h2.tools.RunScript.process(RunScript.java:255)
at org.h2.tools.RunScript.process(RunScript.java:188)
at org.h2.tools.RunScript.process(RunScript.java:319)
at org.h2.tools.RunScript.runTool(RunScript.java:142)
at org.h2.tools.RunScript.main(RunScript.java:69)
It works if I specify the absolute path to dropschemas.sql but that's not a good way to build my script.
How do I create a master script that runs other scripts in a portable manner?
Thanks
Michael