现在我遇到了一个问题,我收到“MySchema”未找到异常:
org.h2.jdbc.JdbcSQLSyntaxErrorException: Schema "MySchema" not found; SQL statement:
select batchstatu0_.batch_key as batch_ke1_0_ from myschema.batch_status batchstatu0_ [90079-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:573)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
当我使用相同的凭据运行从 Oracle SQL Developer 生成的 sql 时,select 语句正确找到架构并运行查询。
我最初尝试成功但不是我想要的解决方案的一件事是为指定的架构指定一个全新的数据源。这很有效,但当我们开始添加事件更多模式时,这将是一个严重的头痛。我更愿意使用一个数据源并在表注释中指定架构。
@Table(name="BATCH_STATUS", schema ="MySchema")
public class BatchStatus {
...
}
以及属性:
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true
hibernate.show_sql=true
spring.datasource.jdbc-url=jdbc:oracle:thin:xxx
spring.datasource.username=xxx
spring.datasource.password=xxx
hibernate.default_schema=MySchema
我认为这一定是某种配置问题,但我无法弄清楚。
最佳答案
您需要指定
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
根据异常(exception)情况,它正在使用 H2 驱动程序
关于spring - 使用 Hibernate 和 Oracle 找不到架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59567177/