-->
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: Hibernate Configuration - connection.datasource
PostPosted: Thu Aug 24, 2006 12:50 pm 
Newbie

Joined: Mon May 08, 2006 10:00 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Hello,

I need to dynamically get the datasource value for various envoirnments like test or production.

Following is my hibernate configuration properties -

hibernate.connection.username=user
hibernate.connection.password=pwd
hibernate.connection.datasource=jdbc/testDB
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.dialect=org.hibernate.dialect.OracleDialect

connection.datasource has test database value - jdbc/testDB.

I need to change it to production value - pordDB, for ear deployment in production.

testDB & prodDB values are mapped in web.xml.

What i need to do to get <connection.datasource> value dynamically change according to the envoirnments.

What are the alternative solutions?

Thanks.

Amit.


Top
 Profile  
 
 Post subject: Re: Hibernate Configuration - connection.datasource
PostPosted: Thu Aug 24, 2006 3:34 pm 
Newbie

Joined: Thu Aug 24, 2006 8:27 am
Posts: 10
amitbuche wrote:
I need to dynamically get the datasource value for various envoirnments like test or production.


For my money, the point of having the datasource defined via JNDI is so that the server can determine which datasource to use. So the JNDI mapping, rather than being defined in your application, is defined on the server, like in server.xml for Tomcat, via the Weblogic console, whatever.

In other words, the server you use for test will have the JNDI datasource mapped to the test database. The production server will have the JNDI datasource pointing at the production database. That way you don't have to change the configuration.

I suppose you could configure Hibernate programmatically, but... that just seems to defeat the purpose.

Another option would be to pass an option into your ant build script and set properties based on that, or just pass in the properties themselves.

Dave


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.