Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate connection.

 
Dave Brown
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to determine when a hibernate session is actually available...

At the start of my program, i'm creating a sessionfactory using the configuration params in my cfg.xml file. Thing is I've deliberately specified a non-existant database name so I can trap that error, to let the user know the database cannot be found.. The problem is , I still get a sessionfactory object and I can still call openSession() without an exception...

Do I need to make a manual jdbc connection just to test if the db can be found or not, or is there some property in one of the hibernate objects I can simply use...

Thanks,
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've noticed that exception usually occurs when you actually run a query. So you can start Hibernate and then run a dummy query and check for success or generated exceptions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic