• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

hibernate connection.

 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Villains always have antidotes. They're funny that way. Here's an antidote disguised as a tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic