Не знаю почему не последняя версия
This commit is contained in:
@ -2,12 +2,14 @@ package kz.goodssales.GoodsSales.dbms;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -66,30 +68,18 @@ public class DBMSTree implements ServletContextAware {
|
||||
String result="<metadata fn=\"-1\"><![CDATA[Request not processed!]]></metadata>";
|
||||
|
||||
String jspPath = context.getRealPath("/");
|
||||
String db_url = "";
|
||||
String db_login = "";
|
||||
String db_password = "";
|
||||
|
||||
//Load DB configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
||||
//File fXmlFile = new File(fullPath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("db-url"))
|
||||
db_url = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("db-login"))
|
||||
db_login = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("db-password"))
|
||||
db_password = nl.item(i).getTextContent();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load application.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
|
||||
Reference in New Issue
Block a user