Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relationships between Spring, Hibernate, JDBC

I just start reading Sun's JDBC tutorial. I installed MySQL Connector/J and was just skimming through its menu, then came across this statement:

"Although JDBC is useful by itself, we would hope that if you are not familiar with JDBC that after reading the first few sections of this manual, that you would avoid using naked JDBC for all but the most trivial problems and consider using one of the popular persistence frameworks such as Hibernate, Spring's JDBC templates or Ibatis SQL Maps to do the majority of repetitive work and heavier lifting that is sometimes required with JDBC"

So what are the relationships between Spring, Hibernate, JDBC? What does the statement mean by saying "avoid using naked JDBC"?

Thanks,

Sarah

like image 853
sarahTheButterFly Avatar asked Oct 22 '10 00:10

sarahTheButterFly


Video Answer


2 Answers

If you use Hibernate, Spring's JDBC templates or Ibatis SQL Maps, you're still using JDBC, but you don't have to deal with it directly. They're doing it for you, and to a degree, insulate you from some difficulties in the use of JDBC.

Hibernate is an object-relational-mapping framework.

MyBatis, formerly known as iBatis, is a data mapping framework.

Spring is a wide-ranging set of web framework components, and includes templating subsystems that allow integration with JDBC, Hibernate, or iBatis and abstract away some of the details of dealing with any of them.

You should indeed learn JDBC, but also (eventually) learn some of these others and try to avoid using JDBC directly for anything very complex.

These ideas are also (especially Hibernate) closely related to the Java Persistence API (JPA), which is also certainly worth learning.

You might also want to look at Java Data Objects (JDO).

Don't try to learn it all at once, though.

Starting with JDBC is a good idea. Staying with it is not.

like image 66
Don Roby Avatar answered Sep 28 '22 07:09

Don Roby


Alphabets > Words > Sentences.

That is how we learn (natural) language.

Similarly, I see:

JDBC API > JDBC API with Connection Pooling > Spring JDBC Template > ORM/JPA/JDO

like image 34
jai Avatar answered Sep 28 '22 08:09

jai