1

I looked over the Internet but I couldn't find any easy tutorials or docs explaining the problem.

I want to connect my JBoss 7.1.1 Final to Oracle Database. I am using Oracle Database 11g Express Edition on 64bit Windows.

The question is what should I do to connect my jboss to Oracle DB?

TheOpti
  • 1,641
  • 3
  • 21
  • 38
  • If you use hibernate you can create a connection there. If not google by the keywords `jboss datasouce oracle` – neshkeev Sep 26 '14 at 14:46
  • I am using mybatis, not hibernate. I also tried googling by the keywords, but I couldn't find anything which could be easily explained. For example, most searching result in tutorials connected with older versions of JBoss... – TheOpti Sep 26 '14 at 14:50
  • [This post](http://middlewaremagic.com/jboss/?p=350) shows you how to configure your datasource in both way using xml file and using administrative console – neshkeev Sep 26 '14 at 15:10

2 Answers2

1

Check this answer jboss 7 oracle datasource configuration

In short, you have to declare a jboss module for your oracle driver. Then, you create your datasource in standalone-xxx.xml and add the reference to the driver.

Finally, you can use this datasource in any persistence.xml by using the jndi-name declared in the datasource.

All of this is explained in the url provided.

Good luck!

Community
  • 1
  • 1
mendieta
  • 3,470
  • 2
  • 20
  • 23
1

You can create JNDI in Jboss 7.1.1 as below and configure mybatis to use this JNDI. make sure you have oracle driver in Modules at com.oracle.ojdbc localtion.

 <subsystem xmlns="urn:jboss:domain:datasources:1.0">
    <datasources>
     <datasource jta="true" jndi-name="java:/jdbc/test" pool-name="test" enabled="true" use-java-context="true" use-ccm="true">
          <connection-url>jdbc:oracle:thin:@localhost:1521:testDB</connection-url> 
          <driver>oracle</driver> 
         <pool>
              <min-pool-size>2</min-pool-size> 
              <max-pool-size>100</max-pool-size> 
              <prefill>false</prefill> 
          </pool>
         <security>
              <user-name>username</user-name> 
              <password>password</password> 
          </security>
         <validation>
              <validate-on-match>false</validate-on-match> 
              <background-validation>false</background-validation> 
          </validation>
      </datasource>

     <drivers>
         <driver name="oracle" module="com.oracle.ojdbc">
            <driver-class>oracle.jdbc.OracleDriver</driver-class> 
            <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class> 
          </driver>
      </drivers>
  </datasources>
  </subsystem>
Neeraj
  • 327
  • 1
  • 8