db-torque-dev 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 Mon, 09 Aug 2004 13:55:05 GMT

I tried to implement a reconfiguration of Torque at runtime following
the advice Guy Galil kindly provided below.

I just changed the URL but I didn't manage to get this change to take

Configuration config = Torque.getConfiguration();
config.setProperty(urlKey, newValue);

What do I need to do to get the new config property value to take effect 
using Torque 3.1?


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);	
> }
> This works well for me.
> I understand that Torque changed since the version I use and my
> modifications to Torque.java are either not needed or not compatible
> with the latest code, I am willing to send my Torque.java if you are
> interested.
> Guy
> On Thu, 2004-08-05 at 11:07, T E Schmitz wrote:
>>I would like to be able to specify the host (not just 
>>dbname/user/pasword) in a login dialog. I can't see how that could be 
>>done other than maybe via Torque.getConfiguration(), where I guess I'd 
>>find the URL.



Tarlika Elisabeth Schmitz

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

View raw message