⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbconstant.java.svn-base

📁 自用的一个简单的数据库连接池
💻 SVN-BASE
字号:
package dev.trade.common.db;

import java.sql.*;

/**
 * <p>Title: 数据库中用到的一些常量定义</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author Lucas
 * @version 1.0
 */
public class DBConstant
{
  private String tag = "";
  private String desc = "";
  private int type = Types.VARCHAR;

  public static final String TAG_PARAM = "PARAM";
  public static final String TAG_NULL = "NULL";
  public static final String TAG_OPER = "OPER";
  public static final String TAG_CHAR = "CHAR";
  public static final String TAG_TABLE = "TABLE";
  public static final String TAG_VIEW = "VIEW";
  public static final String TAG_OTHER = "OTHER";
  public static final DBConstant NULL_STRING = new DBConstant(TAG_NULL, "null", Types.VARCHAR);
  public static final DBConstant NULL_BOOLEAN = new DBConstant(TAG_NULL, "null", Types.BOOLEAN);
  public static final DBConstant NULL_NUMERIC = new DBConstant(TAG_NULL, "null", Types.NUMERIC);
  public static final DBConstant NULL_DATE = new DBConstant(TAG_NULL, "null", Types.DATE);
  public static final DBConstant NULL_TIME = new DBConstant(TAG_NULL, "null", Types.TIME);
  public static final DBConstant NULL_TIMESTAMP = new DBConstant(TAG_NULL, "null", Types.TIMESTAMP);
  public static final DBConstant NULL_STRUCT = new DBConstant(TAG_NULL, "null", Types.STRUCT);
  public static final DBConstant NULL_CLOB = new DBConstant(TAG_NULL, "null", Types.CLOB);
  public static final DBConstant NULL_BLOB = new DBConstant(TAG_NULL, "null", Types.BLOB);
  public static final DBConstant NULL_OTHER = new DBConstant(TAG_NULL, "null", Types.NULL);
  public static final DBConstant PARAM_IS_NULL = new DBConstant(TAG_PARAM,"is null");
  public static final DBConstant PARAM_IS_NOT_NULL = new DBConstant(TAG_PARAM,"is not null");
  public static final DBConstant PARAM_NULL = new DBConstant(TAG_PARAM, "null");
  public static final DBConstant PARAM_SYSDATE = new DBConstant(TAG_PARAM, "sysdate");
  public static final DBConstant PARAM_EMPTY_BLOB = new DBConstant(TAG_PARAM, "empty_blob()");
  public static final DBConstant PARAM_EMPTY_CLOB = new DBConstant(TAG_PARAM, "empty_clob()");
  public static final DBConstant TABLE_DUAL = new DBConstant(TAG_TABLE, "dual");
  public static final DBConstant CHAR_BLANK = new DBConstant(TAG_CHAR, " ");
  public static final DBConstant CHAR_QUOTE = new DBConstant(TAG_CHAR, "'");
  public static final DBConstant CHAR_ASTERISK = new DBConstant(TAG_CHAR, "*");
  public static final DBConstant CHAR_QUESTION = new DBConstant(TAG_CHAR, "?");
  public static final DBConstant CHAR_PERCENT = new DBConstant(TAG_CHAR, "%");
  public static final DBConstant CHAR_LBRACKET = new DBConstant(TAG_CHAR, "(");
  public static final DBConstant CHAR_RBRACKET = new DBConstant(TAG_CHAR, ")");
  public static final DBConstant OPER_SELECT = new DBConstant(TAG_OPER, "select");
  public static final DBConstant OPER_FROM = new DBConstant(TAG_OPER, "from");
  public static final DBConstant OPER_WHERE = new DBConstant(TAG_OPER, "where");
  public static final DBConstant OPER_INSTO = new DBConstant(TAG_OPER, "insert into");
  public static final DBConstant OPER_VALUES = new DBConstant(TAG_OPER, "values");
  public static final DBConstant OPER_UPDATE = new DBConstant(TAG_OPER, "update");
  public static final DBConstant OPER_SET = new DBConstant(TAG_OPER, "set");
  public static final DBConstant OPER_DELETE = new DBConstant(TAG_OPER, "deltete");
  public static final DBConstant OPER_NOT = new DBConstant(TAG_OPER, "not");
  public static final DBConstant OPER_AND = new DBConstant(TAG_OPER, "and");
  public static final DBConstant OPER_OR = new DBConstant(TAG_OPER, "or");
  public static final DBConstant OPER_NULL = new DBConstant(TAG_OPER, "null");
  public static final DBConstant OPER_IS = new DBConstant(TAG_OPER, "is");
  public static final DBConstant OPER_IN = new DBConstant(TAG_OPER, "in");
  public static final DBConstant OPER_LIKE = new DBConstant(TAG_OPER, "like");
  public static final DBConstant OPER_EQUAL = new DBConstant(TAG_OPER, "=");

  private DBConstant(String tag, String desc){
    type = Types.VARCHAR;
    this.tag = tag;
    this.desc = desc;
  }

  private DBConstant(String tag, String desc, int type){
    this.tag = tag;
    this.desc = desc;
    this.type = type;
  }

  public static DBConstant getDBConstant(String desc){
    return new DBConstant("PARAM", desc);
  }

  public static DBConstant getDBConstant(String tag, String desc){
    return new DBConstant(tag, desc);
  }

  public static DBConstant getDBConstant(String tag, String desc, int type){
    return new DBConstant(tag, desc, type);
  }

  public String getTag(){
    return tag;
  }

  public String getDesc(){
    return desc;
  }

  public int getType(){
    return type;
  }

  public String toString(){
    return desc;
  }

  public boolean equals(Object obj){
    if(this == obj)
      return true;
    if(obj instanceof DBConstant){
      DBConstant param = (DBConstant)obj;
      return tag.equals(param.tag) && desc.equals(param.desc) && type == param.type;
    } else{
      return false;
    }
  }

}

⌨️ 快捷键说明

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