0

我正在使用 grails 独立插件来创建一个独立的 grails 应用程序,但我得到一个 jdbc h2 异常。似乎数据库不是在运行时创建的。

我该如何解决这个问题?

这里例外

org.h2.jdbc.JdbcSQLException: Table "COMPANY" not found; SQL statement:
select this_.id as id15_0_, this_.version as version15_0_, this_.name as name15_0_ from company this_ limit ? [42102-164]

    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.command.Parser.readTableOrView(Parser.java:4753)

    at org.h2.command.Parser.readTableFilter(Parser.java:1080)

    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1686)

    at org.h2.command.Parser.parseSelectSimple(Parser.java:1793)

    at org.h2.command.Parser.parseSelectSub(Parser.java:1680)

    at org.h2.command.Parser.parseSelectUnion(Parser.java:1523)

    at org.h2.command.Parser.parseSelect(Parser.java:1511)

    at org.h2.command.Parser.parsePrepared(Parser.java:405)

    at org.h2.command.Parser.parse(Parser.java:279)

    at org.h2.command.Parser.parse(Parser.java:251)

    at org.h2.command.Parser.prepareCommand(Parser.java:217)

    at org.h2.engine.Session.prepareLocal(Session.java:415)

    at org.h2.engine.Session.prepareCommand(Session.java:364)

    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1121)

    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71)

    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:267)

    at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281)

    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:313)

    at grails.orm.PagedResultList.<init>(PagedResultList.java:55)

    at com.kodigon.sensexplorer.survey.CompanyController.list(CompanyController.groovy:19)

    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)

    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)

    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)

    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)

    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)

    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)

    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:380)

    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)

    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    at java.lang.Thread.run(Thread.java:744)
4

2 回答 2

1

H2 将创建数据库,它可能不会创建您期望的模式。您可以在 DataSource.groovy 中的 URL 中添加以下内容:

INIT=CREATE SCHEMA IF NOT EXISTS TEST

所以你会有类似的东西:

url = jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;INIT=CREATE SCHEMA IF NOT EXISTS TEST
于 2013-10-26T23:33:07.537 回答
-1

虽然有点旧,但它可以在未来帮助其他人,就我而言,只是没有包含更改日志,所以经过研究

链接有助于理解我遇到的问题,类似于 如何使用独立插件创建带有 h2 db 的独立 grails 应用程序?

话虽如此,我创建了一个新的并包含生成的迁移,它就像一个魅力......

于 2019-09-27T00:32:58.930 回答