Hello, 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 effect:
Configuration config = Torque.getConfiguration(); config.setProperty(urlKey, newValue); Torque.setConfiguration(config);
What do I need to do to get the new config property value to take effect using Torque 3.1?
Regards, Tarlika
PS: I mistakenly sent this reply to the dev list a couple of days ago, sorry about that)
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:
Hello,
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.
--
Regards/Gruß,
Tarlika Elisabeth Schmitz
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]