db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From T E Schmitz <mail...@numerixtechnology.de>
Subject Re: Specify hostname upon DB connect
Date Sun, 08 Aug 2004 09:06:40 GMT
Hello Guy,

Thank you for posting your solution,

I am using Torque 3.1 and I just had a look at Torque.java. I didn't
spot any re-entrancy problems there.
We really just need this feature during the test phase. I have only one
login at application start and from then on the application accesses the
same DB.

As far as I can see your changeDbHost(...) would do the trick!

Thanks again,

Guy Galil wrote:

> We change database host as well as other properties at runtime.
> We are using an old version of Torque - 3.02
> In order to achieve this I had to modify org.apache.torque.Torque.java
> so that it is re-entrant and added a reConfig(Configuration c) method.
> Then in my code I created a utility class that can be used to change the
> configuration at runtime:
> public static  void changeDbHost(String logicName, String host) throws
> TorqueException
> {
> 	Configuration config = Torque.getConfiguration();
> 	replaceProperty(config,URL.replaceAll("logic_name",logicName),"jdbc:mysql://"+host+"/TURBINE");
> 	Torque.reConfig(config);
> }
> public static void replaceProperty(Configuration config, String key,
> String value)
> {
> 	if(config.containsKey(key))
> 		config.setProperty(key, value);
> 	else
> 		config.addProperty(key, value);	
> }



Tarlika Elisabeth Schmitz

To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message