You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Philippe PONSONNET <ph...@yahoo.fr> on 2004/12/04 01:35:45 UTC
Access to a database with a configuration file
Hello,
I would like to use a database with struts without using the default
datasource.
I also would like to configure all acces of this database with a xml file
named database.xml.
The goal of this is to have a really independant model.
So I have developped a special class named Database which uses the
database.xml file for its connection.
All my classes which map a table use this class. Like that, it is not
nessecary to add some code in my action classes to connect the database.
But I have a problem when I want to load the database.xml file : I can't get
its path when my webapp is loaded.
The instruction getClass().getResource(".").getFile() always return null.
How could I do ?
Thanks in advance and sorry for my poor english.
Philippe