SQLCode.java
上传用户:quasar007
上传日期:2022-08-11
资源大小:4067k
文件大小:1k
- 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());
- }
- }
- }