-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to change port in a connection string in H.
PostPosted: Tue Aug 01, 2006 8:23 pm 
Newbie

Joined: Tue Aug 01, 2006 7:37 pm
Posts: 7
How can I change the port number in Hibernate.cfg.xml on the fly. The current connection string I am using is like:

jdbc:jtds:sqlserver://xxx:1433;DatabaseName=myDB;instance=SQLEXPRESS;SelectMethod=Cursor;namedPipe=true.

The port used above is 1433, but this number can be changed based on what database server is using.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 3:40 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Before or after creating SessionFactory?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 1:40 pm 
Newbie

Joined: Tue Aug 01, 2006 7:37 pm
Posts: 7
before creating SessionFactory


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 2:00 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
instead of something like this
Code:
SessionFactory sf = new Configuration().configure().buildSessionFactory();

try something like this
Code:
Configuration cfg = new Configuration().configure();
cfg.setProperty("hibernate.connection.url", "jdbc:jtds:sqlserver://xxx:1433;DatabaseName=myDB;instance=SQLEXPRESS;SelectMethod=Cursor;namedPipe=true");
SessionFactory sf = cfg.buildSessionFactory();


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 2:39 pm 
Newbie

Joined: Tue Aug 01, 2006 7:37 pm
Posts: 7
Thank you very much, that works.

Just curious, if it happens after buildSessionFactory, what should I do?

Two other questions,
1. ) new Configuration().configure().buildSessionFactory(); is kind of slow, is there anyway to make it faster?

2.) Do you have a good example of buildingHibernate connectionPool , transaction/session management to share?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 5:11 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
a posible solution after creating SessionFactory:
Hibernate Reference wrote:
You may define your own plugin strategy for obtaining JDBC connections by implementing the interface
org.hibernate.connection.ConnectionProvider. You may select a custom implementation by setting hibernate.
connection.provider_class.


For question 1: I suggest you make a new topic.

For question 2: Caveat Emptor Download this application and have a look, mainly to the HibernateUtil class.

Don't forget to rate my answers if they are useful.


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