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
30 ARRAY(Types.ARRAY),
31 BIT(Types.BIT),
32 TINYINT(Types.TINYINT),
33 SMALLINT(Types.SMALLINT),
34 INTEGER(Types.INTEGER),
35 BIGINT(Types.BIGINT),
36 FLOAT(Types.FLOAT),
37 REAL(Types.REAL),
38 DOUBLE(Types.DOUBLE),
39 NUMERIC(Types.NUMERIC),
40 DECIMAL(Types.DECIMAL),
41 CHAR(Types.CHAR),
42 VARCHAR(Types.VARCHAR),
43 LONGVARCHAR(Types.LONGVARCHAR),
44 DATE(Types.DATE),
45 TIME(Types.TIME),
46 TIMESTAMP(Types.TIMESTAMP),
47 BINARY(Types.BINARY),
48 VARBINARY(Types.VARBINARY),
49 LONGVARBINARY(Types.LONGVARBINARY),
50 NULL(Types.NULL),
51 OTHER(Types.OTHER),
52 BLOB(Types.BLOB),
53 CLOB(Types.CLOB),
54 BOOLEAN(Types.BOOLEAN),
55 CURSOR(-10),
56 UNDEFINED(Integer.MIN_VALUE + 1000),
57 NVARCHAR(Types.NVARCHAR),
58 NCHAR(Types.NCHAR),
59 NCLOB(Types.NCLOB),
60 STRUCT(Types.STRUCT),
61 JAVA_OBJECT(Types.JAVA_OBJECT),
62 DISTINCT(Types.DISTINCT),
63 REF(Types.REF),
64 DATALINK(Types.DATALINK),
65 ROWID(Types.ROWID),
66 LONGNVARCHAR(Types.LONGNVARCHAR),
67 SQLXML(Types.SQLXML),
68 DATETIMEOFFSET(-155),
69 TIME_WITH_TIMEZONE(Types.TIME_WITH_TIMEZONE),
70 TIMESTAMP_WITH_TIMEZONE(Types.TIMESTAMP_WITH_TIMEZONE);
71
72 public final int TYPE_CODE;
73 private static Map<Integer,JdbcType> codeLookup = new HashMap<>();
74
75 static {
76 for (JdbcType type : JdbcType.values()) {
77 codeLookup.put(type.TYPE_CODE, type);
78 }
79 }
80
81 JdbcType(int code) {
82 this.TYPE_CODE = code;
83 }
84
85 public static JdbcType forCode(int code) {
86 return codeLookup.get(code);
87 }
88
89 }