1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #350444 Reply

    Andrew Cheng

    <bean id=”sessionFactory”
    <property name=”configLocation” value=”file:src/hibernate.cfg.xml”>
    <property name=”dataSource” ref=”dataSource”></property>

    <bean id=”dataSource”
    <property name=”driverClassName” value=”com.mysql.jdbc.Driver” />
    <property name=”url”
    value=”jdbc:mysql://localhost:3306/test” />
    <property name=”username” value=”root” />
    <property name=”password” value=”admin” />

    I worked on the tutorial HibernateSpringProject
    However, the database connect always use hibernate.cfg.xml but not from dataSource bean. Why we spend time on creating dataSource?

    #350466 Reply


    As we have used ‘org.springframework.orm.hibernate4.LocalSessionFactoryBean’ class for sessionFactory bean in our example, it is mandatory to have a datasource bean definition in the spring applicationConetext.xml file. But only the ‘url’ property is necessary for connection pooling and the rest of the properties ‘driver_class’,’username’ and ‘password’ properties under datasource bean are not mandatory. Perhaps these properties are loaded from hibernate.cfg.xml.

    Our tutorials are just to help you get started. For better understanding on spring development, I suggest you to post on more appropriate development forums (for example, http://www.stackoverflow.com ).

    Hope this helps and let us know if you see any issues in MyEclipse.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: applicationContext.xml

You must be logged in to post in the forum log in