I don't believe you can get this sort of logic to work. Here's why: The "database" name in Torque actually refers to Torque's object space "database" and not any physical SQL Server database. The Torque db name is defined in your schema xml (name attribute on Database tag). This name is used as a key to tie a lot of information together.
Behind the scenes, there is a fair amount of information embedded in the generated classes that is retrieved by the database name. For example, the object database space "meta" data that is contained in the Map classes is grouped by this database name. This means that even though it looks like the properties are just a name that tie in JDBC info together and you should be able to swap this in and out, they really aren't. To use all the capablities of Torque, the database name part of the properties should map to the schema name. That said, here's what I do to deal with this situation. I treat configuration information as being totally separate from application code. It's for configuration after all and so any code updates should not change it. So, while I may have a sample config file checked into the repository, I never have a real configuration property checked in. In my code, I initialize Torque by searching the class path for the configuration file. E.g.: URL url = this.getClass().getClassLoader().getResource( getDbParameterFileName()); // Note: Don't use new URI(url.toString()) // - Tomcat will not resolve this!. String path = url.getPath(); if ( path != null && ! path.startsWith("/")) { path = "/"+path; } URI uri = new URI(url.getProtocol(),"",path,null); return new File(uri); This lets me have different configuration files for various situations, like for junit testing under Eclipse, a development server using MySQL, and multiple production servers using different DB's but all using the same code. > -----Original Message----- > From: Helge Weissig [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 12, 2006 11:45 AM > To: torque-user@db.apache.org > Subject: using a second database > > > Hi, > > I am trying to use a second database but am having > trouble accessing > it (or configuring it, not sure). Below is what I have so far, most > of it taken straight from the 3.2 distribution. When I ask Torque to > give me a connection to "oracle", I get the mysql db connection. > > Also and unrelated, I use the generator to create the mysql > DB and it > seems that I need to use the same name in my DB schema as I > do in the > Torque.properties file for runtime. Is that correct? Is there a way > around it? Having a group of developers develop on their own sandbox > dbs and then switching the code to production would be a little > easier if one would only have to change that DB name in one > place and > not in two and on several lines... > > thanks so much for any insight!! > h. > > # defaults > torque.applicationRoot = ${applicationRoot} # do I > need this one??? > torque.defaults.pool.maxWait = 10000 > torque.defaults.pool.maxIdle = 8 > torque.defaults.pool.maxActive = 10 > torque.defaults.pool.timeBetweenEvictionRunsMillis= 300000 > torque.defaults.pool.minEvictableIdleTimeMillis = 3600000 > torque.defaults.connection.driver = com.mysql.jdbc.Driver > torque.defaults.connection.url = > jdbc:mysql://localhost:3306/test > torque.defaults.connection.user = <user1> > torque.defaults.connection.password = <password1> > > # first DB, works like a charm > torque.database.default=test > torque.database.test.adapter=mysql > torque.dsfactory.test.factory=org.apache.torque.dsfactory.Shar > edPoolData > SourceFactory > torque.dsfactory.test.pool.maxIdle=8 > torque.dsfactory.test.pool.maxActive=10 > torque.dsfactory.test.pool.testOnBorrow=true > torque.dsfactory.test.pool.validationQuery=SELECT 1 > torque.dsfactory.test.connection.driver = > com.mysql.jdbc.Driver torque.dsfactory.test.connection.url = > jdbc:mysql://localhost:3306/test > torque.dsfactory.test.connection.user = <user1> > torque.dsfactory.test.connection.password = <password1> > > # second DB > torque.database.oracle.adapter=oracle > torque.dsfactory.oracle.factory=org.apache.torque.dsfactory.Sh > aredPoolDa > taSourceFactory > torque.dsfactory.oracle.pool.maxIdle=8 > torque.dsfactory.oracle.pool.maxActive=10 > torque.dsfactory.oracle.pool.testOnBorrow=true > torque.dsfactory.oracle.pool.validationQuery=SELECT 1 > torque.database.oracle.driver=oracle.jdbc.driver.OracleDriver > torque.database.oracle.url=jdbc:oracle:thin:@sunfire:1521:actx > torque.database.oracle.username=<user2> > torque.database.oracle.password=<password2> > torque.database.oracle.maxConnections=4 > torque.database.oracle.expiryTime=3600000 > > torque.idbroker.clever.quantity=true > torque.manager.useCache = true > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > Duke CE Privacy Statement Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed. If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately. Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]