Announcement Announcement Module
Collapse
No announcement yet.
How to use multiple JNDI's in a single web application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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



    Venkat

  • #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" />
    </property>
    </bean>


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


    Now we can inject sessionFactory object to our DAO .

    Thanks
    Venkat Jalli

    Comment

    Working...
    X