I am currently developing a web application, I have an XML file named File.xml containing PostgreSQL connection parameters: login, password, ip_address, pilote, port, bdd. . I added this file to the bin folder of Apache Tomcat. I have class.jav which use the parameters of XML file to connect to the data base.
When I run the class I get the result of the else
line (File not found). I doubt that the class does not access the File.xml under the apache bin folder. what to do?
private ParamBDD()
{
SAXBuilder sxb = new SAXBuilder();
try
{
mes_documents mes=new mes_documents();
Fichier fichier = new Fichier();
File file=new File("File.xml");
//File file=new File(this.getClass().getResource("/resources/Fichiers_parametres/parametreconnexion_crypte.xml").getFile());
String str_fichier ="File.xml";
if (file.isFile())
{
org.jdom.Document document = sxb.build(new File(str_fichier));
Element racine = document.getRootElement();
List listParam = racine.getChildren("param");
Iterator i = listParam.iterator();
while (i.hasNext())
{
Element courant = (Element) i.next();
pilote = courant.getChild("pilote").getText().trim();
utilisateur = courant.getChild("login").getText().trim();
password = courant.getChild("password").getText().trim();
adresseIP = courant.getChild("adresseIP").getText().trim();
port = courant.getChild("port").getText().trim();
BDDGenerale = courant.getChild("bdd").getText().trim();
System.out.println("BDD Generale:"+BDDGenerale);
//JOptionPane.showMessageDialog(null, "Fin du fichier","",JOptionPane.INFORMATION_MESSAGE);
}
}
else JOptionPane.showMessageDialog(null, "le fichier contenant les parametres n'existe pas","",JOptionPane.INFORMATION_MESSAGE);
}