Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I am working on JPA- Hibernate, Can you please help me how to refer datasource in jpacontext.xml to

magesh_bAug 19 2016 — edited Aug 21 2016

Hello,

This is my datasource information in tomcat server's context.xml

<Resource name="jdbc/xxx" auth="Container"

              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"

              url="jdbc:oracle:thin:@host:port:schema"

              username="yyy" password="****" maxActive="20" maxIdle="10"

              maxWait="-1"/>

this is how I refer it in web.xml

<resource-ref>

  <description>DB</description>

  <res-ref-name>jdbc/xxx</res-ref-name>

  <res-type>javax.sql.DataSource</res-type>

  <res-auth>Container</res-auth>

  </resource-ref>

In the below lines of jpaContext.xml, I need to refer to the above mentioned JNDI from context.xml, instead of directly writing the username/password and database name(as I did)

<bean id="dataSource"

  class="org.springframework.jdbc.datasource.DriverManagerDataSource">

  <property name="driverClassName" value="oracle.jdbc.OracleDriver " />

  <property name="url" value="jdbc:oracle:thin:@host:port:schema" />

  <property name="yyy" value="decom" />

  <property name="password" value="***" />

  </bean>

Comments
Post Details
Added on Aug 19 2016
1 comment
600 views