zoukankan      html  css  js  c++  java
  • Spring 数据初始 H2 后进行数据查询提示 Schema not found 错误

    在运行测试的错误有提示下面的错误:

    Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Schema "DBO" not found; SQL statement:
    select myscofile0_.id as id1_1_0_, myscofile0_.dateC as datec2_1_0_, myscofile0_.dateM as datem3_1_0_, myscofile0_.uuid as uuid4_1_0_, myscofile0_.client_id as client_i5_1_0_, myscofile0_.file_name as file_nam6_1_0_, myscofile0_.file_row_count as file_row7_1_0_, myscofile0_.file_status as file_sta8_1_0_ from dbo.MYSCOFILE myscofile0_ where myscofile0_.id=? [90079-200]
    	at org.h2.message.DbException.getJdbcSQLException(DbException.java:576)
    	at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
    	at org.h2.message.DbException.get(DbException.java:205)
    	at org.h2.message.DbException.get(DbException.java:181)
    	at org.h2.command.Parser.readTableFilter(Parser.java:1940)
    	at org.h2.command.Parser.parseSelectFromPart(Parser.java:2827)
    

    问题和解决

    出现上面的问题是在 JPA 实例的时候配置了 schema = "dbo, 但是 H2 数据库进行初始化的时候没有创建 schema。

    针对上面的问题,你需要在你的 H2 初始化的时候创建一个 schema。

    创建 schema 的脚本为:

    CREATE SCHEMA IF NOT EXISTS DBO;
    SET SCHEMA DBO;
    

    通过添加下面的脚本,将会在 H2 中创建 Schema,然后可以通过控制台中查看创建的情况。

    在完成上面的配置后,再重新运行你的测试,你就会看到上面的错误已经没有错误了。

    https://www.ossez.com/t/spring-h2-schema-not-found/605

  • 相关阅读:
    struts2 标签 前台遍历 字符串数组 String[]
    007-服务器域名&上传网站
    006-DOS命令
    005-OSI七层模型&IP地址
    004-编程语言发展史
    003-计量单位
    002-B/S架构&C/S架构
    001-计算机的组成
    1083. List Grades (25)
    1037. Magic Coupon (25)
  • 原文地址:https://www.cnblogs.com/huyuchengus/p/13861749.html
Copyright © 2011-2022 走看看