Results 1 to 5 of 5

Thread: Two different datasource

  1. #1

    Default Two different datasource

    I have two different datasource as below one is from pool(jndiName) and the other one is from defaultObject

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>java:/myPool</value>
    </property>
    <property name="resourceRef">
    <value>true</value>
    </property>
    <property name="defaultObject" ref="myDataSource"/>
    </bean>

    <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    </bean>

    Advantage of using the two different datasource is, if connection pool get fail automatically defaultObject will be used...

    Question:
    In my case, if problem in connection pool, getting java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    Then tehre is no use of JndiObjectFactoryBean...
    what i have done mistake ?

  2. #2
    Join Date
    Oct 2008
    Location
    Poland, Wrocław
    Posts
    431

    Default

    Hi

    "The Network Adapter could not establish the connection" is usually Oracle's way of telling that your code cannot connect to properly configured database.

    So it probably isn't problem with Spring - it looks like your placeholders are properly configured. Just there is no database (or SID) at the specified location.

    regards
    Grzegorz Grzybek

  3. #3

    Default

    I tried the connection as follows,

    1) Commented the defaultObject and bean "myDataSource" tried with connection using jndi no issue


    2) Commented the jndi property and connection was success

    It shows clearly no issue in the placeholders.

  4. #4
    Join Date
    Oct 2008
    Location
    Poland, Wrocław
    Posts
    431

    Default

    By "no issue" you mean "no connection" or "no problems"?

    what app server do you use (in the sense of JNDI provider)?

  5. #5

    Default

    I can able to get the connection...only if i used any one( jndi or defaultObject )

    app server is jboss-4.2.3

    If i used both jndi and defaultObject
    and defining the wrong configuration in jndi

    Expected output:
    If jndi fails the connection should get from defaultObject
    Acutal output:
    I am getting the exception as "The Network Adapter could not establish the connection"
    what might be the issues...?
    Last edited by springbeginners; Feb 5th, 2010 at 02:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •