-->
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: Change hibernate.cfg.xml by code
PostPosted: Thu Oct 16, 2008 4:21 am 
Newbie

Joined: Fri Jun 20, 2008 8:56 am
Posts: 15
Hello everyone.

How could I change "hibernate.connection.url" by code?
I meen if there is an instruction to access to hibernate.cfg.xml file and change hibernate.connection.url. I´m woeking with Java and Netbeans.

Thank´s.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2008 6:22 am 
Beginner
Beginner

Joined: Tue Sep 09, 2008 5:42 am
Posts: 22
Location: Romania
Ciao,

I use NHibernate and this is how I dinamically set the connection string inside the hibernate.cfg.xml file:

Code:
            Configuration config = new Configuration().Configure();
            config.SetProperty("connection.connection_string", connectionString);
            sessionFactory = config.AddAssembly(Assembly.GetExecutingAssembly()).BuildSessionFactory();


I hope this can help you figure out how to solve your problem with Java.
Good luck !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2008 6:38 am 
Newbie

Joined: Fri Jun 20, 2008 8:56 am
Posts: 15
Thank´s, that´s what I was looking for :)


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.