简体   繁体   中英

database schema name in persistence.xml

I wanted to know what is the way to mention database schema name in persistence.xml file.

Here is my file.

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
             version="1.0">
    <persistence-unit name="ORDER"
                      transaction-type="RESOURCE_LOCAL">
        <provider>
        org.eclipse.persistence.jpa.PersistenceProvider
    </provider>
        <properties>
            <property name="javax.persistence.jdbc.driver"
                      value="oracle.jdbc.OracleDriver"/>
            <property name="javax.persistence.jdbc.url"
                      value="xyzurl"/>
            <property name="javax.persistence.jdbc.password" value="YYYYY"/>
            <property name="javax.persistence.jdbc.user" value="XXXX"/>
        </properties>
    </persistence-unit>
</persistence>

The schema name is testdta.

Any inputs will be helpful.

Specify your schema name in against the javax.persistence.jdbc.user property.

<property name="javax.persistence.jdbc.user" value="testdta"/>
<property name="javax.persistence.jdbc.password" value="schema password"/>

In case you are not aware, specify the datasource URI here:

<property name="javax.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:service"/>

Have a look at this link. This page explains how you can create persistence.xml for an Oracle database.

https://docs.oracle.com/cd/E16439_01/doc.1013/e13981/cfgdepds005.htm

Here is an example for toplink.jdbc.user property: (It is in TopLink of course!)

<properties>
    <property name="toplink.logging.level" value="INFO"/>
    <property name="toplink.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
    <property name="toplink.jdbc.url" value="jdbc:oracle:thin:@myhost:l521:MYSID"/>
    <property name="toplink.jdbc.password" value="tiger"/>
    <property name="toplink.jdbc.user" value="scott"/>
</properties>

Here, scott is the schema used for connecting to database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM