paip.获取proxool的配置  xml读取通过jdk xml 初始化c3c0在代码中



 xml读取通过jdk xml

初始化c3c0在代码中。。

。。。





作者Attilax  艾龙,  EMAIL:1466519819@qq.com

来源:attilax的专栏

地址:http://blog.csdn.net/attilax





proxoolController.ini();
 

ComboPooledDataSource  dataSource=new   ComboPooledDataSource();       

          dataSource.setUser( proxoolController.user);       

          dataSource.setPassword( proxoolController.pwd);       

          dataSource.setJdbcUrl( proxoolController.url );

          dsx=dataSource;





 

--------------------------- proxoolController--------------  

 

 public static void ini() {

if(url==null)

{

String s=god.getClassPath()+"/proxool.xml";

String xml_str=fileC0.Read(s);

System.out.println(getValue("",xml_str));

}

 



 

System.out.println("f" );

}





public static String getValue(String keyName,String xml_s)   {

//1.获得DocumentBuilderFactory  对象

DocumentBuilderFactory  builderFactory=DocumentBuilderFactory .newInstance();

//2。获得DocumentBuilder对象

DocumentBuilder documentBuilder;

try {

documentBuilder = builderFactory.newDocumentBuilder();



//3.使用documentBuilder来解析XML生成Document对象

Document document=documentBuilder.parse(new InputSource( new StringReader( xml_s ) ) );

document.normalize(); // 删除非XML数据

NodeList nodeList=document.getElementsByTagName("driver-url");

Node node=nodeList.item(0);





NodeList li2=document.getElementsByTagName("property");

for(int i=0;i<li2.getLength();i++)

{

Node nd=li2.item(i);

String name=   nd.getAttributes().getNamedItem("name").getTextContent();

String value=   nd.getAttributes().getNamedItem("value").getTextContent();

if(name.equals("user"))

user=value;

if(name.equals("password"))

pwd=value;

}



url=node.getTextContent();

url=url.trim();

url=url.replace('\n', ' ');

url=url.replace('\t', ' ');url=url.trim();

return node.getTextContent();





} catch ( Exception e) {

 

e.printStackTrace();

}

return null;





}

paip.获取proxool的配置 xml读取通过jdk xml 初始化c3c0在代码中总结的更多相关文章

  1. Java获取路径方法&相对路径读取xml文件方法

    (1).request.getRealPath("/");//不推荐使用获取工程的根路径 (2).request.getRealPath(request.getRequestURI ...

  2. Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)

    <bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil& ...

  3. proxool的配置

    //依赖的包:commons-logging-api-1.1.jar,commons-logging-1.0.4.jar,proxool-0.9.1.jar,proxool-cglib.jar,cgl ...

  4. Spring中配置和读取多个Properties文件--转

    public class PropertiesFactoryBeanextends PropertiesLoaderSupportimplements FactoryBean, Initializin ...

  5. Spring中配置和读取多个Properties文件

    一个系统中通常会存在如下一些以Properties形式存在的配置文件 1.数据库配置文件demo-db.properties: database.url=jdbc:mysql://localhost/ ...

  6. 封装游戏配表读取和存储(xml格式);支持行列存取,标题存取

    做服务器肯定会涉及到游戏配表,而读取游戏配表是一个必备技能; 之前一直都是采用TinyXml直接读,匹配字符串,每次加个表都是一大坨代码,看着也是心累; 因此利用了闲暇的时间封装了一个 xml配置表 ...

  7. c# XML读取

    System.Xml 命名空间 https://msdn.microsoft.com/zh-cn/library/gg145036(v=vs.110).aspx 一.读取 1.通过 XmlDocume ...

  8. Java读取CSV和XML文件方法

    游戏开发中,读取策划给的配置表是必不可少的,我在之前公司,策划给的是xml表来读取,现在公司策划给的是CSV表来读取,其实大同小异,也并不是什么难点,我就简单分享下Java如何读取XML文件和CSV文 ...

  9. 读取properties和xml中配置文件的值

    五种方式让你在java中读取properties文件内容不再是难题 在java中读取properties和xml文件中的方法:https://www.cnblogs.com/ConfidentLiu/ ...

随机推荐

  1. Visual Studio 必备神器

    会使用工具是人类文明的一大进步,今天敏捷大行其道,好的工具可以大大的提高生产力,这里说的工具都是VS平台上的扩展工具,一些机械的部分可以交给工具去处理,自己多关注其他部分.下面分享下我觉得不错的工具, ...

  2. 第一章 git指令与设置

    相关指令: 1.从远程的master分支上创建新的分支,此时新分支内容与master分支内容相同: git checkout master; git branch newbranch; git che ...

  3. iOS 1 到 iOS 10 ,我都快老了

    iOS 1:iPhone诞生 虽然很难想像,但初代iPhone在问世时在功能方面其实远远落后于那时的竞争对手,比如Windows Mobile.Palm OS.塞班.甚至是黑莓.它不支持3G.多任务. ...

  4. mysql 日志

    1.error_log 记录mysql的启动关闭的信息 记录mysql服务器运行错误的信息 记录mysql的表检查或修复信息 路径:my.cnf中通过--log-error=[file_name]配置 ...

  5. each函数

  6. Visual Studio Professional 2015 key

    Visual Studio Professional 2015 Key : HMGNV-WCYXV-X7G9W-YCX63-B98R2 Visual Studio Enterprise 2015 Ke ...

  7. 新浪微博SDK的使用

    花了两天时间研究了一下新浪微博SDK,遇到了不少问题,有必要整理一下 1.首先下载下weiboSdk,导入weiboSDKD和weiboSDKDemo两个项目,这时发现导入的weiboSDKDemo项 ...

  8. 【Visual Lisp】变体与安全数组

    (vlax-make-variant) ;;创建一个未初始化的变体 ;;01.整型值变体(setq myvar (vlax-make-variant 10)) ;;创建整型值变体,返回 #<va ...

  9. C++语法之-------strcpy,memcpy,memset

    1.strcpy 原型:extern char *strcpy(char *dest,char *src); 用法:#i nclude 功能:把src所指由NULL结束的字符串复制到dest所指的数组 ...

  10. Shiro-多Realm验证

    1.多Realm验证 存在这样一种场景,同一个密码可能在MqSQL中存储,也可能在Oracle中存储,有可能MqSQL中使用的是MD5加密算法,而Oracle使用SHA1加密算法.这就需要有多个Rea ...