3 Replies Latest reply on Feb 11, 2009 11:34 AM by ts chuah

    EJB3 on Oracle

    ts chuah Newbie

      Hi All,

      I am new in Java technology and Jboss. Currently, I am trying to working on EJB3, JPA on Oracle DB, But I have no clue how to configure to make it work?

      Anyone can give me some helpful website or guide me how to save the data into Oracle database?

      Thanks in advance.

        • 1. Re: EJB3 on Oracle
          jaikiran pai Master

          Are you looking specifically for Oracle DB or are you looking for tutorials around JPA Entities in EJB3? For the latter, you can refer this http://www.jboss.org/jbossejb3/docs/. You can download the tutorial from that location. The download will include a guide as well. If you want to see the online guide for working with entities, then its here:


          Making this work for Oracle DB is as simple as

          1) changing one config file (persistence.xml)
          2) Creating the oracle datasource http://www.jboss.org/community/docs/DOC-9328
          3) Adding the oracle jdbc driver jar file to %JBOSS_HOME%/server/< serverName>/lib folder.

          • 2. Re: EJB3 on Oracle
            ts chuah Newbie

            Thanks for your fast response.

            I have configured the persistence.xml as below:

            <persistence-unit name="examplePersistenceUnit">

            and created Oracle database source (oracle-ds.xml) in deployed folder.

            <?xml version="1.0" encoding="UTF-8"?>

            <!-- ===================================================================== -->
            <!-- -->
            <!-- JBoss Server Configuration -->
            <!-- -->
            <!-- ===================================================================== -->

            <!-- $Id: oracle-ds.xml 23720 2004-09-15 14:37:40Z loubyansky $ -->
            <!-- ==================================================================== -->
            <!-- Datasource config for Oracle originally from Steven Coy -->
            <!-- ==================================================================== -->


            Here are a couple of the possible OCI configurations.
            For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm


            Clearly, its better to have TNS set up properly.
            <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
            <!-- Checks the Oracle error codes and messages for fatal errors -->
            <!-- sql to call when connection is created
            <new-connection-sql>some arbitrary sql</new-connection-sql>

            <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
            <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>

            <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->



            Is it enough to link to oracle database?

            • 3. Re: EJB3 on Oracle
              ts chuah Newbie

              Yes, I can connect to Oracle DB after defined the persistence.xml and data source file (oracle-ds.xml).

              But how can i save the data to the db? can someone give me a sample to save to database?