• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

learning the parts of the database connections, who does what?

 
Robert Spero
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am just learning java but have a very good comfort level with databases and i want to be sure i understand this. I am looking at developung an app for an existing database using hibernate. Am i understand this correctly in that with jdbc and hibernate these are two different layers meaninf one manages the connection and hibernate manages accessing the data meaning that hibernate will not work with jdbc because hibernate does not manage the connection jdbc does or do i have this wrong?

 
Paul Clapham
Sheriff
Posts: 21559
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. And no.

Yes, Hibernate and JDBC are two separate layers, and your descriptions of them are reasonably good. But in fact Hibernate does work with JDBC, in that Hibernate uses JDBC to access the database. (As any Java code must do if it wants to access a database.) As for "managing" the connection, there really isn't much managing to be done. All that's really necessary is to open the connection before trying to use it. And when Hibernate does that, it does it via JDBC. So yes, they really are two layers, and Hibernate sits on top of JDBC.
 
Robert Spero
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul!
 
Zachary Pry
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Robert,

I would like to add something to Paul's answer.

JDBC supports SQL Databases and allows executing SQL queries in Java.
Plus of it is that is it fast, but require manual handling of classes/types and require proper resource managing.

Hibernate is ORM Framework which allows user(developer) to work with Java Classes instead of SQL queries. Hibernate translates Java Classes into SQL and executes them using JDBC.
Plus of it is that is simple and manages a lot of SQL/JDBC related issues for user(developer) but is not as fast as JDBC.

For beginner - I am advising to use Hibernate as it is simpler and allows to focus on Java and Java Classes instead of learning SQL and SQL Databases/JDBC nuances.

Hope it helps.
 
Robert Spero
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really the sql is the easy part for me, it is the web dev that is new to me. I am spiraling again because i am using googles gwt implementation and i want to make aone time database connection with multi client queries. and i do not know if this is an rpc or request factory. If request factory than why use hibernate?
 
Zachary Pry
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understood your post correctly - you want to use JDBC and Pooled DataSource.

Please look at my answer given in your other topic: http://www.coderanch.com/forums/posts/list/615300#2810082
In there I shared links to Pooled DataSource description and basics of JDBC.

Hope it helps.

---
update:

I see that you already looked at it, never mind then...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic