1 24 25 package com.mckoi.database.global; 26 27 32 33 public class TypeUtil { 34 35 38 public static int toDBType(Class clazz) { 39 if (clazz == String .class) { 40 return Types.DB_STRING; 41 } 42 else if (clazz == java.math.BigDecimal .class) { 43 return Types.DB_NUMERIC; 44 } 45 else if (clazz == java.util.Date .class) { 46 return Types.DB_TIME; 47 } 48 else if (clazz == Boolean .class) { 49 return Types.DB_BOOLEAN; 50 } 51 else if (clazz == ByteLongObject.class) { 52 return Types.DB_BLOB; 53 } 54 else { 55 return Types.DB_OBJECT; 56 } 57 } 58 59 62 public static Class toClass(int type) { 63 if (type == Types.DB_STRING) { 64 return String .class; 65 } 66 else if (type == Types.DB_NUMERIC) { 67 return java.math.BigDecimal .class; 68 } 69 else if (type == Types.DB_TIME) { 70 return java.util.Date .class; 71 } 72 else if (type == Types.DB_BOOLEAN) { 73 return Boolean .class; 74 } 75 else if (type == Types.DB_BLOB) { 76 return ByteLongObject.class; 77 } 78 else if (type == Types.DB_OBJECT) { 79 return Object .class; 80 } 81 else { 82 throw new Error ("Unknown type."); 83 } 84 } 85 86 87 88 89 } 90 | Popular Tags |