Announcement Announcement Module
No announcement yet.
How to use multiple JNDI's in a single web application Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use multiple JNDI's in a single web application

    Hi, I am working on SpringWebMVC along with Hibernate.
    In my appln. ,tables are located in in different databace Scema's.
    I want to fetch the data from those tables located in diff. Scema's.
    To access those tables, I want to create diff. JNDI's for each schema.

    How can we do this in Spring, plz help me in this.

    Thanks in advance


  • #2
    Myself found a solution to this problem.
    I have created two separate JNDI's for diff. databases and I have injected a different SessionFactory object to each datasource.

    Examle code:

    <jee:jndi-lookup id="myDataSource1" jndi-name="jdbc/myDataSource1" expected-type="javax.sql.DataSource" />

    <jee:jndi-lookup id="myDataSource2" jndi-name="jdbc/myDataSource2" expected-type="javax.sql.DataSource" />

    <bean id="mySessionFactory1"
    class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource">
    <ref bean="myDataSource1" />

    <bean id="mySessionFactory2"
    class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource">
    <ref bean="myDataSource2" />

    Now we can inject sessionFactory object to our DAO .

    Venkat Jalli