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
| package db;
|
| public enum SupportDBTypeEnum {
| /**
| * MySQL数据库
| */
| mysql,
|
| /**
| * Oracle数据库
| */
| oracle,
|
| /**
| * Postgre数据库
| */
| postgre,
|
| /**
| * SQLServer数据库
| */
| sqlserver;
|
| /**
| * @param type 数据库类型名
| * @return support DBType
| */
| public static SupportDBTypeEnum getEnum(String type) {
| if (type == null || "".equals(type = type.trim())) {
| throw new IllegalArgumentException("The database type can not be NULL");
| }
|
| SupportDBTypeEnum result = null;
| try {
| result = SupportDBTypeEnum.valueOf(type);
| return result;
| } catch (Throwable e) {
| // ignore
| }
|
| for (SupportDBTypeEnum supportType : SupportDBTypeEnum.values()) {
| if (supportType.name().equalsIgnoreCase(type)) {
| return supportType;
| }
| }
|
| if (result == null) {
| throw new IllegalArgumentException("The database type with name '" + type + "' is not support");
| }
| return result;
| }
| }
|
|