Access Oracle9iAS DataSoruce hibernate-spring

Sreedhar
2004-08-11
2004-08-11
  • Sreedhar

    Sreedhar - 2004-08-11

    Hi,

    I want to configure Oracle9iAS datasource ( data-source.xml ) in hibernate-spring.xml. what tags(Syntax) should i use in hibernate-spring.xml to configure  Oracle9iAS DataSource.

    Thanks,
    Sreedhar

     
    • smiles

      smiles - 2004-08-11

      I’m assuming hibernate-spring.xml represents your application context.  If so, all you’d need to do is define your data-source.xml to include the location attr such as
      <data-source  class="com.evermind.sql.DriverManagerDataSource"  name="yourApplicationDS" location="jdbc/yourNonTXDataSource" ...>

      The application context could then reference that datasource using

      <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName">
        <value>java:comp/env/jdbc/yourNonTXDataSource</value>
      </property>
      </bean>

      If you&#8217;d like more flexibility between environments, substitute a properties file parm for the value where the properties file is also defined in your application context

      <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
          <list>
            <value>WEB-INF/jdbc.properties</value>
          </list>
        </property>
      </bean>

      <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName">
        <value>${myapp.jndi.datasource}</value>
      </property>
      </bean>

       
      • Sreedhar

        Sreedhar - 2004-08-11

        Thanks a lot for your help. Can you check for me correct syntax..?

        <beans>

        <bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiName">
                <value>java:comp/env/jdbc/xxxxDS</value>
              </property>
            </bean>

        <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
                <property name="mappingResources">
                    <list>
                        <value>com/xxxx/persistence/model/xxx.hbm.xml</value>
                    </list>
                </property>

                  <property name="hibernateProperties">
                    <props>
                      <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
                    </props>
                  </property>
                  <property name="dataSource">
                    <ref bean="myDataSource"/>
                  </property>
            </bean>

        </beans>

        Let me know thanks a lot for your help

         
        • smiles

          smiles - 2004-08-11

          well from the 'eye-ball' pov things look ok.  but i can barely catch my own spelling errors.

          give it a whirl and if there is a specific error let me know.

           

Log in to post a comment.