1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.type;
17
18 import java.sql.Types;
19 import java.util.HashMap;
20 import java.util.Map;
21
22
23
24
25 public enum JdbcType {
26
27
28
29 ARRAY(Types.ARRAY),
30
31 BIT(Types.BIT),
32
33 TINYINT(Types.TINYINT),
34
35 SMALLINT(Types.SMALLINT),
36
37 INTEGER(Types.INTEGER),
38
39 BIGINT(Types.BIGINT),
40
41 FLOAT(Types.FLOAT),
42
43 REAL(Types.REAL),
44
45 DOUBLE(Types.DOUBLE),
46
47 NUMERIC(Types.NUMERIC),
48
49 DECIMAL(Types.DECIMAL),
50
51 CHAR(Types.CHAR),
52
53 VARCHAR(Types.VARCHAR),
54
55 LONGVARCHAR(Types.LONGVARCHAR),
56
57 DATE(Types.DATE),
58
59 TIME(Types.TIME),
60
61 TIMESTAMP(Types.TIMESTAMP),
62
63 BINARY(Types.BINARY),
64
65 VARBINARY(Types.VARBINARY),
66
67 LONGVARBINARY(Types.LONGVARBINARY),
68
69 NULL(Types.NULL),
70
71 OTHER(Types.OTHER),
72
73 BLOB(Types.BLOB),
74
75 CLOB(Types.CLOB),
76
77 BOOLEAN(Types.BOOLEAN),
78
79 CURSOR(-10),
80
81 UNDEFINED(Integer.MIN_VALUE + 1000),
82
83 NVARCHAR(Types.NVARCHAR),
84
85 NCHAR(Types.NCHAR),
86
87 NCLOB(Types.NCLOB),
88
89 STRUCT(Types.STRUCT),
90
91 JAVA_OBJECT(Types.JAVA_OBJECT),
92
93 DISTINCT(Types.DISTINCT),
94
95 REF(Types.REF),
96
97 DATALINK(Types.DATALINK),
98
99 ROWID(Types.ROWID),
100
101 LONGNVARCHAR(Types.LONGNVARCHAR),
102
103 SQLXML(Types.SQLXML),
104
105 DATETIMEOFFSET(-155),
106
107 TIME_WITH_TIMEZONE(Types.TIME_WITH_TIMEZONE),
108
109 TIMESTAMP_WITH_TIMEZONE(Types.TIMESTAMP_WITH_TIMEZONE);
110
111 public final int TYPE_CODE;
112 private static final Map<Integer, JdbcType> codeLookup = new HashMap<>();
113
114 static {
115 for (JdbcType type : JdbcType.values()) {
116 codeLookup.put(type.TYPE_CODE, type);
117 }
118 }
119
120 JdbcType(int code) {
121 this.TYPE_CODE = code;
122 }
123
124 public static JdbcType forCode(int code) {
125 return codeLookup.get(code);
126 }
127
128 }