I am working on a project
servlet whose purpose is to receive an xml file and, based on some characteristics of the xml, perform a set of operations on an Advantage Database (not exactly my database of choice, but it's not my decision). The servlet is running on resin, and I'm connecting to the database using the Jdbc-Odbc Bridge.
A little background on advantage (at least the version I have to use) -- there are no dictionaries or anything like that. Basically, a database is just a collection of .adt files in a directory.
Initially, I was working with one database. I set up a User DSN in the Windows Control Panel, entered in the directory of the databse in options, and gave it the name "Database". Then in my resin.conf, I put this:
<database>
<jndi-name>
java:/BenDB</jndi-name>
<driver>
<type>sun.jdbc.odbc.JdbcOdbcDriver</type>
<url>
jdbc
dbc:Database</url>
</driver>
<max-connections>20</max-connections>
<max-idle-time>30s</max-idle-time>
</database>
In my app, I connect to the database using it's jndi name -- java:/BenDB.
Here's the problem I'm having -- a field (call it i.d.) in the xml tells me which database (of many) I need to connect to. I have a properties file that is a mapping between ids and directories:
1=c:\firstDB\data
2=c:\secondDB\data
...
My question is, I guess, how can I change which database the getConnection() method connects to on the fly? I suppose I *could* create User DSN's and JNDI names for each of the databases (somewhere between 8 and 10) and bloat up my resin.conf, but that seems kind of distasteful. Any ideas?
[edited to disable smilies]
[ December 22, 2004: Message edited by: Jeanne Boyarsky ]