• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database connection in hibernate

 
p hasini
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We specify the Database connection in hibernate.cfg.xml file.

Is this file loaded when we start the server?

Does the application connect to the database only once during startup , or each time we perform the CRUD operations.I mean is there a opening and closing of a database connection each time we perform an operation on the database.
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
p hasini wrote:We specify the Database connection in hibernate.cfg.xml file. Is this file loaded when we start the server?

Hibernate does that when initializing.
Does the application connect to the database only once during startup , or each time we perform the CRUD operations.

Normal practice is to use the connection pool provided by the application server.
I mean is there a opening and closing of a database connection each time we perform an operation on the database.

In case of connection pooling connection object (handle) returns to the pool when you close it in your code. You can configure Hibernate to use the connection pooling.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic