These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to test connection
PostPosted: Sun Jun 22, 2008 2:03 pm 
Newbie

Joined: Sun Jun 22, 2008 1:57 pm
Posts: 11
Hi,

I'm a newbie with Hibernate, I created a dialog to enter database connection. I want put a button "Test connection" on it. How can I test connection data with hibernate? My first idea was to open a session and it works even if the database name does not exist in the server.

Thanks for anyhelp,
C-Rock


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 22, 2008 3:05 pm 
Newbie

Joined: Sun Jun 22, 2008 1:57 pm
Posts: 11
Hi,

I found the solution: I open an hibernate session. This does not throw an exception as I expeted. But the Connection property is an exception object instead of a connection object. Therefore, I tested it like this:

Code:
if (_session.Connection is Exception)
{
    throw new HibernateException("Unable to get the connect to the database", _session.Connection as Exception);


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.