Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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!