Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Spring with Hibernate Integrating Hibernate with Spring Create a SessionFactory and DataSource

Jean Loughran
Jean Loughran
1,148 Points

Data Source vs hibernate config file

Hi, I am new to Spring and Db connections. The code for the hibernate config file - as in the DB driver and the URL seems the same as the Data source driver and Url. What is the difference between the 2? Theory wise my understanding is that the hibernate config file tells hibernate how to connect to the database. The datasource allows Spring to get connection to the database with connection pooling - and the same driver and url is used here. I cant really understand the difference - Does the data source kind of wrap hibernate as in add more functionality ie DBCP? Are we telling Spring again where the driver and URL is in the basic data source object? Sorry if question is muddled, it is reflecting my brain!