-->
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.  [ 3 posts ] 
Author Message
 Post subject: Checking DB Availibiltiy without ConnectionProviderFactory
PostPosted: Wed Jun 11, 2014 8:27 am 
Newbie

Joined: Tue Apr 17, 2007 8:01 am
Posts: 6
Location: Krefeld - Germany
Hello,
I'm migrating from 3.5.1 to 4.3.5.
In 3.5.1 im testing if I can login to the DB Server and then I check the DB structure.
Im doing it on the client side, in a normal Java Application.

In Hibernate 3.5.1 I simply do
Code:
ConnectionProvider connectionProvider = ConnectionProviderFactory.newConnectionProvider(config.getProperties());

Connection connection = connectionProvider.getConnection();
connection.close();
connectionProvider.close();

with a try/catch around it.

But in 4.3.5 there's no ConnectionProviderFactory.
Since im on the client side, I can't do the @Inject mechanism, that is described in another thread in this forum (Or I dont know how).
How can I check he DB Connection from a normal JRE client?

Thanks in advance for your help


Top
 Profile  
 
 Post subject: Re: Checking DB Availibiltiy without ConnectionProviderFactory
PostPosted: Wed Jun 11, 2014 9:46 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Hi,
ConnectionProvider is a Service so you should be able to obtain it from the serviceRegistry.

I haven't tried it but it should be something like;

Code:
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
ConnectionProvider connectionProvider = serviceRegistry.getService(ConnectionProvider.class);


or

Code:
ConnectionProvider connectionProvider = sessionFactory.getSessionFactoryOptions().getServiceRegistry().getService(ConnectionProvider.class);


Hope this help,
Davide


Top
 Profile  
 
 Post subject: Re: Checking DB Availibiltiy without ConnectionProviderFactory
PostPosted: Wed Jun 11, 2014 9:58 am 
Newbie

Joined: Tue Apr 17, 2007 8:01 am
Posts: 6
Location: Krefeld - Germany
Great!
I'm using the first solution to check the connection before the sessionFactory is created.
Thanks a lot for the quick reply!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.