-->
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.  [ 1 post ] 
Author Message
 Post subject: How to test if username and password to database are correct
PostPosted: Wed Feb 21, 2007 2:19 pm 
Newbie

Joined: Sun Feb 11, 2007 12:04 pm
Posts: 2
Hello,
how to test if username and password to database are correct (and generally, connection settings) ?
I use this code (and I also use C3P0 connection pooler):
Code:
    Session s = getSessionFactory().getCurrentSession();
    s.beginTransaction();
    s.connection().createStatement();
    s.getTransaction().commit();

When no exception happened, username and password are correct.

But this approcha looks ugly to me and I have also problem that when connection isn't valid, hibernate try to connect for cca. 30 seconds and entire application freezes (even if connection test runs in separate thread).

Is there any other possibility how to test it, or at least how to force hibernate to test database connection for only 5 seconds or to force hibernate not to "freeze" application?

Thank you for your answers.

_________________
---------------------
Jakub Maler
www.simpleway.cz


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

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.