1821349743@qq.com
2023-02-20 93dd9bc3f16b0f626761ec624f2dc78037568897
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.product.data.config;
 
 
/**
 * @Author cheng
 * @Date 2022/2/5 16:46
 * @Desc 数据库类型
 */
public enum DatabaseType {
 
    Oracle(DbValueConfig.Oracle, "oracle.jdbc.driver.OracleDriver", "select 1 from dual"),
    MySql(DbValueConfig.MySql, "com.mysql.cj.jdbc.Driver", "SELECT 1"),
    SqlServer(DbValueConfig.SqlServer, "com.microsoft.sqlserver.jdbc.SQLServerDriver", "SELECT 1"),
    Informix(DbValueConfig.Informix, "com.informix.jdbc.IfxDriver", "select count(*) from systables"),
    PSQL(DbValueConfig.PSQL, "org.postgresql.Driver", "select 1 "),
    ;
 
    public static DatabaseType
 
    getDataBaseType(int type) {
        DatabaseType[] values = DatabaseType.values();
        for (DatabaseType value : values) {
            if (value.value.getValue() == type) {
                return value;
            }
        }
        return null;
    }
 
 
    private DbValueConfig value;
    private String validationQuery;
 
    private String driver;
 
 
    DatabaseType(DbValueConfig value, String driver, String validationQuery) {
        this.validationQuery = validationQuery;
        this.driver = driver;
        this.value = value;
    }
 
    public int getValue() {
        return value.value;
    }
 
    public String getValidationQuery() {
        return validationQuery;
    }
 
    public String getDriver() {
        return driver;
    }
}