当前位置: 首页 > 知识库问答 >
问题:

H2数据库:如何为表名设置小写?

淳于博
2023-03-14

>

  • 我希望所有表名都保持小写。示例person

    我使用Liquibase设置数据库,它看起来像

       <cargo.datasource.datasource.earth>
            cargo.datasource.driver=${h2.driver}|
            cargo.datasource.url=${datasource.url}|
            cargo.datasource.jndi=${datasource.jndi}|
            cargo.datasource.username=${h2.user}|
            cargo.datasource.password=${h2.user}
        </cargo.datasource.datasource.earth>
    
    <datasource.url>jdbc:h2:${project.build.directory}/earth;DATABASE_TO_UPPER=false</datasource.url>
    
    INFO 9/22/14 3:32 PM:liquibase: Successfully acquired change log lock
    INFO 9/22/14 3:32 PM:liquibase: Dropping Database Objects in schema: UNIT-TESTING-PU.PUBLIC
    INFO 9/22/14 3:32 PM:liquibase: Creating database history table with name: PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: Creating database history table with name: PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: Successfully released change log lock
    INFO 9/22/14 3:32 PM:liquibase: Successfully acquired change log lock
    INFO 9/22/14 3:32 PM:liquibase: Reading from PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: Reading from PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: Reading from PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/01.xml::09222014.0639::harit: Reading from PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/01.xml::09222014.0639::harit: Table person created
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/01.xml::09222014.0639::harit: ChangeSet liquibase/2014/01.xml::09222014.0639::harit ran successfully in 1ms
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/01.xml::09222014.0639::harit: Reading from PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: Reading from PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: ChangeSet liquibase/2014/02.xml::09222014.0844::harit ran successfully in 3ms
    INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: Reading from PUBLIC.DATABASECHANGELOG
    INFO 9/22/14 3:32 PM:liquibase: Successfully released change log lock
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.929 sec
    Running com.learner.integration.HelloIT
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.443 sec
    Running com.learner.integration.PersonsIT
    [INFO] [talledLocalContainer] 15:32:59,145 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-15) SQL Error: 42102, SQLState: 42S02
    [INFO] [talledLocalContainer] 15:32:59,146 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-15) Table "Person" not found; SQL statement:
    [INFO] [talledLocalContainer] select person0_.id as id1_0_, person0_.firstName as firstNam2_0_, person0_.lastName as lastName3_0_ from Person person0_ [42102-181]
    [INFO] [talledLocalContainer] 15:32:59,153 ERROR [org.jboss.as.ejb3.invocation] (default task-15) JBAS014134: EJB Invocation failed on component PersonManager for method public java.util.List com.learner.business.manager.PersonManager.getPersons(): javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
    [INFO] [talledLocalContainer]   at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:190) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
    [INFO] [talledLocalContainer]   at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
    [INFO] [talledLocalContainer]   at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:340) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
    [INFO] [talledLocalContainer]   at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
    [INFO] [talledLocalContainer]   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
    [INFO] [talledLocalContainer]   at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
    [INFO] [talledLocalContainer]   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
    

    问题
    如何告诉h2我的表都是小写->Person而不是Person

  • 共有1个答案

    钱飞翼
    2023-03-14

    尝试在H2连接URL设置“database_to_upper=false”中使用。

     类似资料:
    • 我使用< code>Liquibase更新我的数据库,并对< code>H2进行测试。 我正在使用来配置属性。我使用 连接到数据库,但没有成功。 我意识到在,所以我尝试将默认模式设置为 但这没有成功,我看到日志是 如何在 H2 中设置默认架构和数据库名称?

    • 本文向大家介绍教你如何在windows与linux系统中设置MySQL数据库名、表名大小写敏感,包括了教你如何在windows与linux系统中设置MySQL数据库名、表名大小写敏感的使用技巧和注意事项,需要的朋友参考一下 在 MySQL 中,数据库和表其实就是数据目录下的目录和文。 因而,操作系统的敏感性决定数据库和表命名的大小写敏感。这就意味着数据库和表名在 Windows 中是大小写不敏感的

    • 我正在使用带有Spring Boot(2.3.3版)的H2数据库和H2数据库的所有默认设置。 这是我申请的所有文件。 pom.xml

    • 我对一个应用程序的JPA层进行了几个单元测试。这个JPA层由JPA实体和一个提供持久化实体所需的基本API的服务组成。单元TET直接使用javax.Persistence类来处理PersistenceManager。然后测试持久性API,我可以在日志中看到创建表和序列等的SQL语句。 persistence.xml文件的相关部分如下所示: 我已经下载了Windows安装程序H2 1.4.200,并

    • 我的应用程序有3个组件, 1) 一种面向用户的组件,接收请求并将其存储到数据库中。2)一个后端组件,从数据库中读取数据,进行处理并将其发送到外部系统。3) 存储用户输入的数据库 我如何测试流程是这样的:用户输入数据- 注意:我尝试使用ddl auto:update,但它不起作用。

    • 问题描述 开发时使用Spring-Boot-Data-JPA操作H2数据库,创建表名为User的表失败 H2中用于保存用户的表是Users,表名应该没有冲突,User是H2数据库的关键字吗? JPA生成的SQL代码中被@Id注释的username字段没有被指定为identifier,但是仅更改表名后可以就正常创建,其他表也都没有这个问题 问题出现的环境背景及自己尝试过哪些方法 Spring-Boo