Joined: Fri Mar 02, 2012 4:10 am Posts: 1
|
I have the following code in the Try bloc :
// Session variable Session session = null; // Connection variable Connection conn = null;
try { ... // Get hibernate session session = getHibernateTemplate().getSessionFactory().openSession(); // Get connection frojm session conn = session.connection(); ... }catch{ ... }
And in the finally bloc i want to bloc all the related object of the connection with the database.
the closing of session makes us to close the connection ? or we have to have to close the connection before ?
Solution 1 :
finally{ try{if (conn!=null) conn.close();}ctach{} try{if (session!=null) session.close();}catch{} }
Solution 2 :
finally{ try{if (session!=null) session.close();}catch{} }
In case of one of the two solutions before, can you explain the relationship between session and connection specially through pool way.
|
|