zoukankan      html  css  js  c++  java
  • Properties类加载属性文件

    Properties类加载属性文件加载是开发中常用的一种方法。可以达到低耦合、高内聚的作用

    注:properties属性文件必须方法src目录下,否则load()加载器无法找到properties属性文件。

    方法如下:

             Properties props = new Properties();

             props.load(new FileInputStream(propertiesname));

             driver = props.getProperty("properties文件中的driver键名")

     url = props.getProperty("properties文件中的url键名")

     user = props.getProperty("properties文件中的user键名")

     pass = props.getProperty("properties文件中的pass键名")

     

    创建好上面的句可以在加载驱动时直接传入如上的变量名作为参数。

     

  • 相关阅读:
    ServletConfig对象
    乱码问题
    response request
    mysql
    数据库三范式 简单理解
    会话 cookie
    ServletContext对象
    读取工程中的配置文件
    Servlet与缓存
    C#捕获异常崩溃时
  • 原文地址:https://www.cnblogs.com/lwltfd-IT/p/7845395.html
Copyright © 2011-2022 走看看