【发布时间】:2019-04-10 02:14:32
【问题描述】:
我有一个现有的 postgres 数据库,其中包含数据库“testdb”和数据库架构 testdbschema”。
如果我使用 RESOURCE_LOCAL 的默认 persistence.xml 配置,则以下属性有效:
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://server:port/testdb?currentSchema=testdbschema" />
我想将我的 web.xml 中的数据库连接配置为数据源。一切都运行良好,除了数据库模式的配置。
这是我的 web.xml 配置:
<data-source>
<name>java:global/myapp</name>
<class-name>org.postgresql.ds.PGSimpleDataSource</class-name>
<server-name>127.0.0.1</server-name>
<port-number>5432</port-number>
<database-name>testdb</database-name>
<user>postgres</user>
<password>postgres</password>
</data-source>
您现在如何在此处配置我的数据库架构名称?
通过 testdb?currentSchema=testdbschema 的配置对我不起作用,我得到一个找不到数据库的失败。
【问题讨论】:
-
你试过了吗
${yourSchema} -
我想在 web.xml 中配置它,而不是在 hibernate persistence.xml 文件中。这个 JDBC 数据源线程没有描述数据库模式的处理。
标签: java postgresql jpa datasource web.xml