我正在尝试在任意文件夹中执行此操作:
java -cp .;e:\tools\h2\bin\* org.h2.tools.RunScript -url myDBURI -script CreateDatabase.sql
CreateDatabase.sql 位于当前文件夹中。
在里面我有:
runscript from 'classpath:/DropSchemas.sql';
我也试过
runscript from 'DropSchemas.sql';
runscript from './DropSchemas.sql';
当我这样做时,我收到 DropSchemas.sql 的文件未找到错误:
线程“主”org.h2.jdbc.JdbcSQLException 中的异常:IO 异常:“java.io.FileNotFoundException:资源 /DropSchemas.sql”;“类路径:/DropSchemas.sql”;SQL 语句:
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)
如果我指定了 dropchemas.sql 的绝对路径,它就可以工作,但这不是构建我的脚本的好方法。
如何创建以可移植方式运行其他脚本的主脚本?
谢谢
迈克尔