提交 | 用户 | age
|
826b66
|
1 |
package com.hx.auto.common; |
C |
2 |
|
|
3 |
/**javaType和jdbcType对比 |
|
4 |
* |
|
5 |
* @author chenjiahe |
|
6 |
* |
|
7 |
*/ |
|
8 |
public class JdbcType { |
|
9 |
|
|
10 |
/** |
|
11 |
* @param type 字段类型 |
|
12 |
* @param isBol 是否长字符串 |
|
13 |
* @return |
|
14 |
*/ |
|
15 |
public static String jdbcTypeData(String type,boolean isBol) { |
|
16 |
//字母转化为小字母 |
|
17 |
type = type.toLowerCase(); |
|
18 |
if(type.equals("java.lang.string")) { |
|
19 |
if(!isBol) { |
|
20 |
type = "VARCHAR"; |
|
21 |
}else { |
|
22 |
type = "LONGVARCHAR"; |
|
23 |
} |
|
24 |
}else if(type.equals("int")) { |
|
25 |
type = "INTEGER"; |
|
26 |
}else if(type.equals("java.lang.integer")) { |
|
27 |
type = "INTEGER"; |
|
28 |
}else if(type.equals("boolean")) { |
|
29 |
type = "BOOLEAN"; |
|
30 |
}else if(type.equals("byte")) { |
|
31 |
type = "TINYINT"; |
|
32 |
}else if(type.equals("short")) { |
|
33 |
type = "SMALLINT"; |
|
34 |
}else if(type.equals("long")) { |
|
35 |
type = "BIGINT"; |
|
36 |
}else if(type.equals("float")) { |
|
37 |
type = "REAL"; |
|
38 |
}else if(type.equals("double")) { |
|
39 |
type = "DOUBLE"; |
|
40 |
}else if(type.equals("java.lang.double")) { |
|
41 |
type = "DOUBLE"; |
|
42 |
}else if(type.equals("java.util.date")) { |
|
43 |
type = "TIMESTAMP"; |
|
44 |
}else if(type.equals("java.sql.date")) { |
|
45 |
type = "TIMESTAMP"; |
|
46 |
}else if(type.equals("blob")) { |
|
47 |
type = "BLOB"; |
|
48 |
} |
|
49 |
return type; |
|
50 |
} |
|
51 |
} |