5 Replies Latest reply on May 11, 2008 3:54 PM by thomas2008ch

    A question about Configure Persistence Context with Oracle

    thomas2008ch

      How can I write the persistence.xml for connection to Oracle Express 10g?

      I've read the documentation from JBoss but I find the docs is not so good.

      Besides, which file should have in which I can put the user name and password for the database?

      Does someone know any documentation about this?

      Regards

      Thomas

        • 1. Re: A question about Configure Persistence Context with Orac
          thomas2008ch

          Here is an example for using HSQL. But how can I set the username and password?

          <persistence>
           <persistence-unit name="ejb3trail">
           <jta-data-source>java:/DefaultDS</jta-data-source>
           <properties>
           <property name="hibernate.hbm2ddl.auto"
           value="create-drop"/>
           </properties>
           </persistence-unit>
          </persistence>
          


          • 2. Re: A question about Configure Persistence Context with Orac
            peterj

            Note that the persistence.xml file references a jta-data-source. You define this in a *-ds.xml file. You can find example *-ds.xml files for a variety of database in docs/examples/jca directory. The database information, such a username and password, go into the *-ds.xml file.

            • 3. Re: A question about Configure Persistence Context with Orac
              thomas2008ch

              OK, I find the file "oracle-ds.xml". It should be the correct one.

              Besides I find some examples from the internet. The "persistence.xml" for Oracle looks as follow:

              <persistence>
               <persistence-unit name="ejb3trail">
               <jta-data-source>java:/OracleDS</jta-data-source>
               <properties>
               <property name="hibernate.hbm2ddl.auto"
               value="create-drop"/>
               </properties>
               </persistence-unit>
              </persistence>
              


              But:
              1.
              WHere can I put this file in my project? Under /META-INF/ ? Where the "persistence.xml" locates?

              2.
              How can the program or the server knows where the file "oracle-ds.xml" locates? Should I change the <jta-data-source/> in "persistence.xml" as follow?
              <persistence>
               <persistence-unit name="ejb3trail">
               <jta-data-source>java:/oracle-ds</jta-data-source>
               <properties>
               <property name="hibernate.hbm2ddl.auto"
               value="create-drop"/>
               </properties>
               </persistence-unit>
              </persistence>
              


              • 4. Re: A question about Configure Persistence Context with Orac
                peterj

                Place the oracle-ds.xml file into the deploy directory and it will be deployed. Leave the jta-data-source as java:/OracleDS. The jta-data-source entry refers to the JNDI name for the data source, which comes from the jndi-name entry within the oracle-ds.xml file.

                The persistence.xml file goes in the META-INF directory.

                • 5. Re: A question about Configure Persistence Context with Orac
                  thomas2008ch

                  Many thanks.