【问题标题】:Error "Schema "information_schema" not found;" running "migrate up" on H2 database错误“未找到架构“information_schema”;”在 H2 数据库上运行“向上迁移”
【发布时间】:2021-07-28 13:48:27
【问题描述】:

我正在一个 ColdBox 应用程序中测试 h2 数据库(在 Lucee 上)... 我可以使用 Quick 连接到数据库,但无法运行迁移...

这是迁移初始化和迁移后CommandBox中显示的错误

ERROR (5.2.1+00295)
Schema "information_schema" not found; SQL statement:SELECT 1 FROM "information_schema"."tables" WHERE "table_name" = ? AND "table_schema" = ? [90079-172]   
MigrationService.cfc
SELECT 1 FROM "information_schema"."tables" WHERE "table_name" = 'cfmigrations' AND "table_schema" = 'testAppDB'

Application.cfc 和 box.json 都使用 ENVIRONMENT 设置:

# ColdBox Name and Environment
APPNAME=tastApp
ENVIRONMENT=development

DB_BUNDLEVERSION=1.3.172
DB_PORT=
DB_USER=sa
DB_BUNDLENAME=org.h2
DB_CLASS=org.h2.Driver
DB_HOST=127.0.0.1
DB_DRIVER=org.h2.Driver
DB_SCHEMA=appDB
DB_DATABASE=appDB
DB_CONNECTIONSTRING=jdbc:h2:/Users/elena/coldbox-examples/testApp/database/appDB;MODE=MySQL;
DB_PASSWORD=

h2 是从 Lucee 下载页面下载并保存在 /lib 文件夹中(我在 box.json 中添加了依赖项)

这是语法设置:

"defaultGrammar":"AutoDiscover@qb"

我错过了什么?

提前谢谢你

埃琳娜


更新 - 5 月 18 日

感谢 Evgenij,

现在我可以查询最新版本的 h2 1.4.200,它接受设置 (CASE_INSENSITIVE_IDENTIFIERS = TRUE),使所有标识符名称(表名、列名)不区分大小写。

不幸的是,使用命令框迁移的迁移仍然给我错误:

这些是我正在使用的当前配置:

"cfmigrations":{
    "migrationsDirectory":"resources/database/migrations",
    "schema":"INFORMATION_SCHEMA",
    "connectionInfo":{
        "bundleName":"com.h2database",
        "bundleVersion":"1.4.200",
        "password":"",
        "connectionString":"jdbc:h2:/Users/elena/coldbox-examples/testApp/database/appDB;MODE=MySQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE;",
        "class":"org.h2.Driver",
        "username":""
    },
    "defaultGrammar":"AutoDiscover@qb"
}

这是最后一个错误:

> * > CLI v5.2.1 > 10:59 AM > ~/coldbox-examples/testApp/ > testApp (1.0.0) >
 lucee 5.3.7 (running) >
> migrate up
ERROR (5.2.1+00295)                                                                                                                                             Unable to resolve com.h2database [108](R 108.0): missing requirement [com.h2database [108](R 108.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.5.0)) 
Unresolved requirements: [[com.h2database [108](R 108.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.5.0))]
  caused by: org.osgi.framework.BundleException
Unable to resolve com.h2database [108](R 108.0): missing requirement [com.h2database [108](R 108.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.5.0)) Unresolved requirements: [[com.h2database [108](R 108.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.5.0))]

【问题讨论】:

    标签: h2 coldbox commandbox


    【解决方案1】:

    H2 1.3.172 非常旧,它无法正确模拟来自 MySQL 的非标准小写 INFORMATION_SCHEMA

    您需要使用最新版本的 H2(例如 1.4.200),并在 JDBC URL 后附加;MODE=MySQL;DATABASE_TO_LOWER=TRUE,仅;MODE=MySQL 是不够的。

    【讨论】:

    • 谢谢 Evgenij;我已经下载了建议的版本并保存在我的冷箱应用程序的 lib finder 中,但现在我遇到了这个错误:版本 [1.4.200] 中名称为 [org.h2] 的 OSGi Bundle 在本地不可用(/Users/ elena/.CommandBox/server/A6BB937D9E26EE318D085EF2B2DB46FA-testApp/lucee-5.3.7.47/WEB-INF/lucee-server/bundles;我错过了什么?
    • 在1.4.198版本更名为com.h2database
    • ok... 这个错误怎么办:无法解析 com.h2database [106](R 106.0): missing requirements [com.h2database [106](R 106.0)] osgi.wiring.package ; (&(osgi.wiring.package=org.osgi.framework)(version>=1.5.0)) 未解决的需求:[[com.h2database [106](R 106.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.5.0))] 引起:org.osgi.framework.BundleException Unable to resolve com.h2database [106](R 106.0): missing要求 [com.h2database [106](R 106.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.5.0)) 未解决的重新...
    • 另一个问题,我希望是最后一个问题:在 H2 1.3.172 中,捆绑包名称是 'h2.org',驱动程序类名称是 'org.h2.Driver... 在 H2 1.4.199 中包名称是“com.h2database”;驱动类名是什么?
    • 它仍然是org.h2.Driver,但是直接使用它很少合适,因为Java 6 / JDBC 4.0驱动程序是自动注册的。
    猜你喜欢
    • 1970-01-01
    • 2021-04-29
    • 2021-05-23
    • 2019-10-06
    • 1970-01-01
    • 2022-11-03
    • 2017-12-26
    • 1970-01-01
    • 2016-01-16
    相关资源
    最近更新 更多