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. FIFO跨时钟域读写

    今天面试,要走时问了我一个问题:如果两个时钟一个时钟慢一个时钟快,来读写FIFO,其中读出的数据是 连续的一段一段的. 图1 图1为写时序控制,可以看出数据是两个时钟周期的长度,当然实际中可以是任意周 ...

  2. ascii文件转为utf-8格式

    import codecs import os #格式转换 fhanzi1 = codecs.open(os.path.join(outputpath,"hanzi1.txt"), ...

  3. instr函数

    在Oracle/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置. 语法如下:instr( string1, string2 [, start_position [, nth_appe ...

  4. 卸载Oracle步骤

    卸载Oracle步骤:1.停止所有与ORACLE相关的服务.2. 使用OUI(Oracle Universal Installer)卸载Oracle软件.   “开始”->“程序”->“O ...

  5. ini_set 设置php配置项 在windows和linux下的不同

    在win下,当你要include多个路径的话,你要用“:”隔开,但在linux下就使用":"隔开的.. if (substr(php_uname(), 0, 7) == " ...

  6. canvas事件

    canvas的事件只能监听在canvas标签上,而不嗯那个想其他dom元素那样,所以针对canvas里面的图形监听事件是比较麻烦的. 通过isPointInPath(x,y);  这个方法用于判断某一 ...

  7. Python模块——bisect

    bisect是python内置的模块,主要用于对有序列进行操作.具体用法如下: 模块导入:import bisect 内容查看:dir(bisect) 这个模块包含了: 五个变量:builtins, ...

  8. 字符串链接strcat

    #include "stdafx.h" #include "iostream" #include "assert.h" #include & ...

  9. php中::的使用方法

    (转载于http://www.nowamagic.net/php/php_UsageOfDoubleColon.php) 双冒号操作符即作用域限定操作符Scope Resolution Operato ...

  10. Xcode升级更新后,恢复cocoapods以及插件的方法

    今天将手机系统更新到iOS9.3了,在Xcode7.1上做真机调试,提示找不到适合的SDK,才知道必须要升级Xcode才行,于是升级Xcode到7.3. 升级之后遇到很多麻烦,cocoapods没有了 ...