package com.engine.organization.util.db;


import com.engine.organization.exception.OrganizationRunTimeException;

public enum DBType implements DBOperateAdapter {
    MYSQL("mysql") {
        @Override
        public String like(String some) {
            return "like '%" + some + "%'";
        }
    },
    SQLSERVER("sqlserver") {
        @Override
        public String like(String some) {
            return "like '%" + some + "%'";
        }
    },
    ORACLE("oracle") {
        @Override
        public String like(String some) {
            return "'%'||" + some + "||'%'";
        }
    };

    private String dbtype;

    DBType(String dbtype) {
        this.dbtype = dbtype;
    }

    public static DBType get(String dbtype) {
        for (DBType t : DBType.values()) {
            if (t.dbtype.equalsIgnoreCase(dbtype)) {
                return t;
            }
        }
        throw new OrganizationRunTimeException("不支持的数据库类型");
    }


}
