My favorite tomcat way connect to a database, it to have tomcat provide a
JDBC connection pool as a global JNDI resource and then my application gets deployed with mapping a JNDI resource reference (from the web.xml) to the tomcat global JNDI name using the context.xml in my war file.
That way, the application module does not have any dependency on the JDBC url (or DSN, which is really a JDBC URL that goes through jdbc:odbc bridge??)
Here is an example, my system is tomcat 5.5 on linux to connect to PostgreSQL.
1) make sure you have the JDBC driver for your database in your tomcat's boot classpath, such as ${TOMCAT_HOME}/common/lib
2) create entry in your ${TOMCAT_BASE}/conf/server.xml that provides the parameters for how to connect to your database. The following example is from my tomcat 5.5 to PostgreSQL (you will have to change the URL for oracle):
in my case, i give it some name that makes sense to me, fmsDB.
Note the <lobalNamingResources> is probably already there in the server.xml
3) add a resource entry in your web.xml to indicate your application is wanting to use a JDBC resource:
4) package a META-INF/context.xml into your .war file (as the top level path META-INF/context.xml. Tomcat seems to understand this, and if it is present, will perform mappings from the web application specific datasource name to the global datasource name. Here is my META-INF/context.xml:
5) start tomcat, inspect to make sure no start up errors (typos in the server.xml. deploy your app, watch logs for errors in finding database drivers in classpath, typos in web.xml.
6) use something, like a jsp test page, inside your application to validate the connection is good. The data source would be available from the JNDI naming context as
java:comp/env/jdbc/fmsDB (in my case)
As a side note, the above
pattern works nicely on windows deployments too, without modification, exactly as it is. (i.e. JDBC connection pooling with JNDI bindings, and indirection to your web app module).
I guess my response was more along "don't use DSN / ODBC to connect web apps, which probably does not help, since you are almost done the project.
So, if you must use DSN on the linux box, there are ODBC implementations available for unix / linux: iodbc.org and easysoft's UnixODBC.
When one of these is installed and configured with a DSN to your Oracle server, the Tomcat JDBC connect URL, or how ever you currently connect to the DSN with in your app, should be able to use it.
[ June 15, 2006: Message edited by: Travis Hein ]