sqlcode.java

来自「客户关系管理系统,包括数据库,类,所有运行所需的代码及文件」· Java 代码 · 共 57 行

JAVA
57
字号
package com.tool;


public final class SQLCode {
  private static SQLCode sqlCode = null;
  private static java.util.Properties sqlCodeProperties = new java.util.
      Properties();

  static {
    sqlCode = new SQLCode();
  }

  private SQLCode() {
    _load();
  }

  //取得sqlcode.properties中的sql语句
  public static String getSQLCode(String sqlKey) {
    String sql = "";

    if (sqlCodeProperties.containsKey(sqlKey)) {
      sql = sqlCodeProperties.getProperty(sqlKey);

    }
    return sql;
  }

  public static SQLCode getInstance() {
    return sqlCode;
  }

  //指向sqlcode.properties的位置
  public void _load() {
    String fileName = "/com/tool/sqlCode.properties";
    //通过指定路径找到资源文件存放在fileName中
    sqlCodeProperties.clear();
    //sqlCodeProperties清空

    try {
      java.io.InputStream in = null;
      try {
        in = getClass().getResourceAsStream(fileName);
        //把fileName中存放值放入in字符流中

        sqlCodeProperties.load(in);
      }
      finally {
        in.close();
      }
    }
    catch (java.io.IOException e) {
      System.out.println(e.getMessage());
    }
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?