public class XMLConfigParser {
private Element elementRoot;
public XMLConfigParser() {
try {
SAXBuilder saxbuilder = new SAXBuilder();
Document doc = saxbuilder.build("configration.xml");
elementRoot = doc.getRootElement();
}
catch (Exception e) {
e.printStackTrace();
}
}
public Element getChildElement(String elementName){
return elementRoot.getChild(elementName);
}
}
import org.jdom.*;
public class InitParameter {
private static XMLConfigParser xmlConfigParser = new XMLConfigParser();
private static Element connPoolE =
xmlConfigParser.getChildElement("connectionpool");
public InitParameter() {
}
public static String getUrl() {
return connPoolE.getChildTextTrim("url");
}
public static String getDatasource() {
return connPoolE.getChildTextTrim("datasource");
}
}