首页 > 编程语言 > 详细

Spring 数据初始 H2 后进行数据查询提示 Schema not found 错误

时间:2020-10-23 09:43:55      阅读:39      评论:0      收藏:0      [点我收藏+]

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

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

Spring 数据初始 H2 后进行数据查询提示 Schema not found 错误

原文:https://www.cnblogs.com/huyuchengus/p/13861749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!