1 30 31 32 package org.hsqldb; 33 34 import org.hsqldb.lib.IntKeyHashMap; 35 import org.hsqldb.lib.IntValueHashMap; 36 import org.hsqldb.lib.HashMap; 37 38 49 public class Types { 50 51 56 public static final String DecimalClassName = "java.math.BigDecimal"; 57 public static final String DateClassName = "java.sql.Date"; 58 public static final String TimeClassName = "java.sql.Time"; 59 public static final String TimestampClassName = "java.sql.Timestamp"; 60 61 68 public static final int ARRAY = 2003; 69 70 75 public static final int BIGINT = -5; 76 77 82 public static final int BINARY = -2; 83 84 91 public static final int BLOB = 2004; 92 93 100 public static final int BOOLEAN = 16; 101 102 107 public static final int CHAR = 1; 108 109 116 public static final int CLOB = 2005; 117 118 124 public static final int DATALINK = 70; 125 126 131 public static final int DATE = 91; 132 133 138 public static final int DECIMAL = 3; 139 140 147 public static final int DISTINCT = 2001; 148 149 154 public static final int DOUBLE = 8; 155 156 161 public static final int FLOAT = 6; 162 163 168 public static final int INTEGER = 4; 169 170 177 public static final int JAVA_OBJECT = 2000; 178 179 184 public static final int LONGVARBINARY = -4; 185 186 191 public static final int LONGVARCHAR = -1; 192 193 198 public static final int NULL = 0; 199 200 205 public static final int NUMERIC = 2; 206 207 213 public static final int OTHER = 1111; 214 215 220 public static final int REAL = 7; 221 222 229 public static final int REF = 2006; 230 231 236 public static final int SMALLINT = 5; 237 238 245 public static final int STRUCT = 2002; 246 247 252 public static final int TIME = 92; 253 254 259 public static final int TIMESTAMP = 93; 260 261 266 public static final int TINYINT = -6; 267 268 273 public static final int VARBINARY = -3; 274 275 280 public static final int VARCHAR = 12; 281 282 289 public static final int XML = 137; 290 291 296 public static final int TYPE_SUB_DEFAULT = 1; 297 298 303 public static final int TYPE_SUB_IGNORECASE = TYPE_SUB_DEFAULT << 2; 304 305 310 static final int[][] ALL_TYPES = { 311 { 312 ARRAY, TYPE_SUB_DEFAULT 313 }, { 314 BIGINT, TYPE_SUB_DEFAULT 315 }, { 316 BINARY, TYPE_SUB_DEFAULT 317 }, { 318 BLOB, TYPE_SUB_DEFAULT 319 }, { 320 BOOLEAN, TYPE_SUB_DEFAULT 321 }, { 322 CHAR, TYPE_SUB_DEFAULT 323 }, { 324 CLOB, TYPE_SUB_DEFAULT 325 }, { 326 DATALINK, TYPE_SUB_DEFAULT 327 }, { 328 DATE, TYPE_SUB_DEFAULT 329 }, { 330 DECIMAL, TYPE_SUB_DEFAULT 331 }, { 332 DISTINCT, TYPE_SUB_DEFAULT 333 }, { 334 DOUBLE, TYPE_SUB_DEFAULT 335 }, { 336 FLOAT, TYPE_SUB_DEFAULT 337 }, { 338 INTEGER, TYPE_SUB_DEFAULT 339 }, { 340 JAVA_OBJECT, TYPE_SUB_DEFAULT 341 }, { 342 LONGVARBINARY, TYPE_SUB_DEFAULT 343 }, { 344 LONGVARCHAR, TYPE_SUB_DEFAULT 345 }, { 346 NULL, TYPE_SUB_DEFAULT 347 }, { 348 NUMERIC, TYPE_SUB_DEFAULT 349 }, { 350 OTHER, TYPE_SUB_DEFAULT 351 }, { 352 REAL, TYPE_SUB_DEFAULT 353 }, { 354 REF, TYPE_SUB_DEFAULT 355 }, { 356 SMALLINT, TYPE_SUB_DEFAULT 357 }, { 358 STRUCT, TYPE_SUB_DEFAULT 359 }, { 360 TIME, TYPE_SUB_DEFAULT 361 }, { 362 TIMESTAMP, TYPE_SUB_DEFAULT 363 }, { 364 TINYINT, TYPE_SUB_DEFAULT 365 }, { 366 VARBINARY, TYPE_SUB_DEFAULT 367 }, { 368 VARCHAR, TYPE_SUB_DEFAULT 369 }, { 370 VARCHAR, TYPE_SUB_IGNORECASE 371 }, { 372 XML, TYPE_SUB_DEFAULT 373 } 374 }; 375 383 384 static final int SQL_CHARACTER = 1; 386 static final int SQL_CHAR = 1; 387 static final int SQL_NUMERIC = 2; 388 static final int SQL_DECIMAL = 3; 389 static final int SQL_DEC = 3; 390 static final int SQL_INTEGER = 4; 391 static final int SQL_INT = 4; 392 static final int SQL_SMALLINT = 5; 393 static final int SQL_FLOAT = 6; 394 static final int SQL_REAL = 7; 395 static final int SQL_DOUBLE = 8; 396 static final int SQL_CHARACTER_VARYING = 12; 397 static final int SQL_CHAR_VARYING = 12; 398 static final int SQL_VARCHAR = 12; 399 static final int SQL_BOOLEAN = 16; 400 static final int SQL_USER_DEFINED_TYPE = 17; 401 static final int SQL_ROW = 19; 402 static final int SQL_REF = 20; 403 static final int SQL_BIGINT = 25; 404 static final int SQL_BINARY_LARGE_OBJECT = 30; 405 static final int SQL_BLOB = 30; 406 static final int SQL_CHARACTER_LARGE_OBJECT = 40; 407 static final int SQL_CLOB = 40; 408 static final int SQL_ARRAY = 50; static final int SQL_MULTISET = 55; static final int SQL_DATE = 91; 411 static final int SQL_TIME = 92; 412 static final int SQL_TIMESTAMP = 93; static final int SQL_TIME_WITH_TIME_ZONE = 94; 414 static final int SQL_TIMESTAMP_WITH_TIME_ZONE = 95; static final int SQL_INTERVAL_YEAR = 101; static final int SQL_INTERVAL_MONTH = 102; 417 static final int SQL_INTERVAL_DAY = 103; 418 static final int SQL_INTERVAL_HOUR = 104; 419 static final int SQL_INTERVAL_MINUTE = 105; 420 static final int SQL_INTERVAL_SECOND = 106; 421 static final int SQL_INTERVAL_YEAR_TO_MONTH = 107; 422 static final int SQL_INTERVAL_DAY_TO_HOUR = 108; 423 static final int SQL_INTERVAL_DAY_TO_MINUTE = 109; 424 static final int SQL_INTERVAL_DAY_TO_SECOND = 110; 425 static final int SQL_INTERVAL_HOUR_TO_MINUTE = 111; 426 static final int SQL_INTERVAL_HOUR_TO_SECOND = 112; 427 static final int SQL_INTERVAL_MINUTE_TO_SECOND = 113; 428 429 static final int SQL_BIT_VARYING = 15; static final int SQL_DATALINK = 70; 437 static final int SQL_UDT = 17; 438 static final int SQL_UDT_LOCATOR = 18; 439 static final int SQL_BLOB_LOCATOR = 31; 440 static final int SQL_CLOB_LOCATOR = 41; 441 static final int SQL_ARRAY_LOCATOR = 51; 442 static final int SQL_MULTISET_LOCATOR = 56; 443 static final int SQL_ALL_TYPES = 0; 444 static final int SQL_DATETIME = 9; static final int SQL_INTERVAL = 10; static final int SQL_XML = 137; 447 448 static final int SQL_DISTINCT = 1; 450 static final int SQL_SCTRUCTURED = 2; 451 452 public static final int VARCHAR_IGNORECASE = 100; 454 455 static IntValueHashMap typeAliases; 458 static IntKeyHashMap typeNames; 459 static HashMap javaTypeNames; 460 461 private static org.hsqldb.lib.HashSet illegalParameterClasses; 467 468 static { 469 typeAliases = new IntValueHashMap(50); 470 471 typeAliases.put("INTEGER", Types.INTEGER); 472 typeAliases.put("INT", Types.INTEGER); 473 typeAliases.put("int", Types.INTEGER); 474 typeAliases.put("java.lang.Integer", Types.INTEGER); 475 typeAliases.put("IDENTITY", Types.INTEGER); 476 typeAliases.put("DOUBLE", Types.DOUBLE); 477 typeAliases.put("double", Types.DOUBLE); 478 typeAliases.put("java.lang.Double", Types.DOUBLE); 479 typeAliases.put("FLOAT", Types.FLOAT); 480 typeAliases.put("REAL", Types.REAL); 481 typeAliases.put("VARCHAR", Types.VARCHAR); 482 typeAliases.put("java.lang.String", Types.VARCHAR); 483 typeAliases.put("CHAR", Types.CHAR); 484 typeAliases.put("CHARACTER", Types.CHAR); 485 typeAliases.put("LONGVARCHAR", Types.LONGVARCHAR); 486 typeAliases.put("VARCHAR_IGNORECASE", VARCHAR_IGNORECASE); 487 typeAliases.put("DATE", Types.DATE); 488 typeAliases.put(DateClassName, Types.DATE); 489 typeAliases.put("TIME", Types.TIME); 490 typeAliases.put(TimeClassName, Types.TIME); 491 typeAliases.put("TIMESTAMP", Types.TIMESTAMP); 492 typeAliases.put(TimestampClassName, Types.TIMESTAMP); 493 typeAliases.put("DATETIME", Types.TIMESTAMP); 494 typeAliases.put("DECIMAL", Types.DECIMAL); 495 typeAliases.put(DecimalClassName, Types.DECIMAL); 496 typeAliases.put("NUMERIC", Types.NUMERIC); 497 typeAliases.put("BIT", Types.BOOLEAN); 498 typeAliases.put("BOOLEAN", Types.BOOLEAN); 499 typeAliases.put("boolean", Types.BOOLEAN); 500 typeAliases.put("java.lang.Boolean", Types.BOOLEAN); 501 typeAliases.put("TINYINT", Types.TINYINT); 502 typeAliases.put("byte", Types.TINYINT); 503 typeAliases.put("java.lang.Byte", Types.TINYINT); 504 typeAliases.put("SMALLINT", Types.SMALLINT); 505 typeAliases.put("short", Types.SMALLINT); 506 typeAliases.put("java.lang.Short", Types.SMALLINT); 507 typeAliases.put("BIGINT", Types.BIGINT); 508 typeAliases.put("long", Types.BIGINT); 509 typeAliases.put("java.lang.Long", Types.BIGINT); 510 typeAliases.put("BINARY", Types.BINARY); 511 typeAliases.put("[B", Types.BINARY); 512 typeAliases.put("VARBINARY", Types.VARBINARY); 513 typeAliases.put("LONGVARBINARY", Types.LONGVARBINARY); 514 typeAliases.put("OTHER", Types.OTHER); 515 typeAliases.put("OBJECT", Types.OTHER); 516 typeAliases.put("java.lang.Object", Types.OTHER); 517 typeAliases.put("NULL", Types.NULL); 518 typeAliases.put("void", Types.NULL); 519 typeAliases.put("java.lang.Void", Types.NULL); 520 521 typeNames = new IntKeyHashMap(); 523 524 typeNames.put(Types.NULL, "NULL"); 525 typeNames.put(Types.INTEGER, "INTEGER"); 526 typeNames.put(Types.DOUBLE, "DOUBLE"); 527 typeNames.put(VARCHAR_IGNORECASE, "VARCHAR_IGNORECASE"); 528 typeNames.put(Types.VARCHAR, "VARCHAR"); 529 typeNames.put(Types.CHAR, "CHAR"); 530 typeNames.put(Types.LONGVARCHAR, "LONGVARCHAR"); 531 typeNames.put(Types.DATE, "DATE"); 532 typeNames.put(Types.TIME, "TIME"); 533 typeNames.put(Types.DECIMAL, "DECIMAL"); 534 typeNames.put(Types.BOOLEAN, "BOOLEAN"); 535 typeNames.put(Types.TINYINT, "TINYINT"); 536 typeNames.put(Types.SMALLINT, "SMALLINT"); 537 typeNames.put(Types.BIGINT, "BIGINT"); 538 typeNames.put(Types.REAL, "REAL"); 539 typeNames.put(Types.FLOAT, "FLOAT"); 540 typeNames.put(Types.NUMERIC, "NUMERIC"); 541 typeNames.put(Types.TIMESTAMP, "TIMESTAMP"); 542 typeNames.put(Types.BINARY, "BINARY"); 543 typeNames.put(Types.VARBINARY, "VARBINARY"); 544 typeNames.put(Types.LONGVARBINARY, "LONGVARBINARY"); 545 typeNames.put(Types.OTHER, "OBJECT"); 546 547 illegalParameterClasses = new org.hsqldb.lib.HashSet(); 549 550 illegalParameterClasses.add(Byte.TYPE); 551 illegalParameterClasses.add(Short.TYPE); 552 illegalParameterClasses.add(Float.TYPE); 553 illegalParameterClasses.add(Byte .class); 554 illegalParameterClasses.add(Short .class); 555 illegalParameterClasses.add(Float .class); 556 557 javaTypeNames = new HashMap(); 559 560 javaTypeNames.put(DateClassName, "java.sql.Date"); 561 javaTypeNames.put(TimeClassName, "java.sql.Time"); 562 javaTypeNames.put(TimestampClassName, "java.sql.Timestamp"); 563 javaTypeNames.put(DecimalClassName, "java.math.BigDecimal"); 564 javaTypeNames.put("byte", "java.lang.Integer"); 565 javaTypeNames.put("java.lang.Byte", "java.lang.Integer"); 566 javaTypeNames.put("short", "java.lang.Integer"); 567 javaTypeNames.put("java.lang.Short", "java.lang.Integer"); 568 javaTypeNames.put("int", "java.lang.Integer"); 569 javaTypeNames.put("java.lang.Integer", "java.lang.Integer"); 570 javaTypeNames.put("long", "java.lang.Long"); 571 javaTypeNames.put("java.lang.Long", "java.lang.Long"); 572 javaTypeNames.put("double", "java.lang.Double"); 573 javaTypeNames.put("java.lang.Double", "java.lang.Double"); 574 javaTypeNames.put("boolean", "java.lang.Boolean"); 575 javaTypeNames.put("java.lang.Boolean", "java.lang.Boolean"); 576 javaTypeNames.put("java.lang.String", "java.lang.String"); 577 javaTypeNames.put("void", "java.lang.Void"); 578 javaTypeNames.put("[B", "[B"); 579 } 580 581 585 static String getFunctionReturnClassName(String methodReturnType) { 586 587 String name = (String ) javaTypeNames.get(methodReturnType); 588 589 return name == null ? methodReturnType 590 : name; 591 } 592 593 600 static int getTypeNr(String type) throws HsqlException { 601 602 int i = typeAliases.get(type, Integer.MIN_VALUE); 603 604 Trace.check(i != Integer.MIN_VALUE, Trace.WRONG_DATA_TYPE, type); 605 606 return i; 607 } 608 609 612 public static String getTypeString(int type) { 613 return (String ) typeNames.get(type); 614 } 615 616 619 public static String getTypeString(int type, int precision, int scale) { 620 621 String s = (String ) typeNames.get(type); 622 623 if (precision != 0 && acceptsPrecisionCreateParam(type)) { 624 StringBuffer sb = new StringBuffer (s); 625 626 sb.append(Token.T_OPENBRACKET); 627 sb.append(precision); 628 629 if (scale != 0 && acceptsScaleCreateParam(type)) { 630 sb.append(Token.T_COMMA); 631 sb.append(scale); 632 } 633 634 sb.append(Token.T_CLOSEBRACKET); 635 636 return sb.toString(); 637 } 638 639 return s; 640 } 641 642 669 static int getParameterTypeNr(Class c) throws HsqlException { 670 671 String name; 672 int type; 673 674 if (c == null) { 675 Trace.doAssert(false, "c is null"); 676 } 677 678 if (Void.TYPE.equals(c)) { 679 return Types.NULL; 680 } 681 682 if (illegalParameterClasses.contains(c)) { 683 throw Trace.error(Trace.WRONG_DATA_TYPE, 684 Trace.UNSUPPORTED_PARAM_CLASS, c.getName()); 685 } 686 687 name = c.getName(); 688 type = typeAliases.get(name, Integer.MIN_VALUE); 689 690 if (type == Integer.MIN_VALUE) { 691 692 if (c.isArray()) { 695 while (c.isArray()) { 696 c = c.getComponentType(); 697 } 698 699 if (c.isPrimitive() 700 || java.io.Serializable .class.isAssignableFrom(c)) { 701 type = OTHER; 702 } 703 } else if (java.io.Serializable .class.isAssignableFrom(c)) { 704 type = OTHER; 705 } 706 } 707 708 Trace.check(type != Integer.MIN_VALUE, Trace.WRONG_DATA_TYPE, name); 709 710 return type; 711 } 712 713 863 static boolean isDatetimeType(int type) { 864 865 switch (type) { 866 867 case DATE : 868 case TIME : 869 case TIMESTAMP : 870 return true; 871 872 default : 873 return false; 874 } 875 } 876 877 884 public static boolean acceptsPrecisionCreateParam(int type) { 885 886 switch (type) { 887 888 case BINARY : 889 case BLOB : 890 case CHAR : 891 case CLOB : 892 893 case VARBINARY : 896 case VARCHAR : 897 case VARCHAR_IGNORECASE : 898 case DECIMAL : 899 case NUMERIC : 900 case FLOAT : 901 case TIMESTAMP : 902 case TIME : 903 return true; 904 905 default : 906 return false; 907 } 908 } 909 910 public static int numericPrecisionCreateParamRadix(int type) { 911 912 switch (type) { 913 914 case Types.DECIMAL : 915 case Types.NUMERIC : 916 return 10; 917 918 case FLOAT : 919 return 2; 920 921 default : 922 923 return 0; 925 } 926 } 927 928 public static boolean acceptsScaleCreateParam(int type) { 929 930 switch (type) { 931 932 case Types.DECIMAL : 933 case Types.NUMERIC : 934 return true; 935 936 default : 937 return false; 938 } 939 } 940 941 public static boolean isNumberType(int type) { 942 943 switch (type) { 944 945 case BIGINT : 946 case DECIMAL : 947 case DOUBLE : 948 case FLOAT : 949 case INTEGER : 950 case NUMERIC : 951 case REAL : 952 case SMALLINT : 953 case TINYINT : 954 return true; 955 956 default : 957 return false; 958 } 959 } 960 961 public static boolean isCharacterType(int type) { 962 963 switch (type) { 964 965 case CHAR : 966 case CLOB : 967 case LONGVARCHAR : 968 case VARCHAR : 969 case VARCHAR_IGNORECASE : 970 return true; 971 972 default : 973 return false; 974 } 975 } 976 977 public static String getTypeName(int type) { 978 979 switch (type) { 980 981 case Types.ARRAY : 982 return "ARRAY"; 983 984 case Types.BIGINT : 985 return "BIGINT"; 986 987 case Types.BINARY : 988 return "BINARY"; 989 990 case Types.BLOB : 991 return "BLOB"; 992 993 case Types.BOOLEAN : 994 return "BOOLEAN"; 995 996 case Types.CHAR : 997 return "CHAR"; 998 999 case Types.CLOB : 1000 return "CLOB"; 1001 1002 case Types.DATALINK : 1003 return "DATALINK"; 1004 1005 case Types.DATE : 1006 return "DATE"; 1007 1008 case Types.DECIMAL : 1009 return "DECIMAL"; 1010 1011 case Types.DISTINCT : 1012 return "DISTINCT"; 1013 1014 case Types.DOUBLE : 1015 return "DOUBLE"; 1016 1017 case Types.FLOAT : 1018 return "FLOAT"; 1019 1020 case Types.INTEGER : 1021 return "INTEGER"; 1022 1023 case Types.JAVA_OBJECT : 1024 return "JAVA_OBJECT"; 1025 1026 case Types.LONGVARBINARY : 1027 return "LONGVARBINARY"; 1028 1029 case Types.LONGVARCHAR : 1030 return "LONGVARCHAR"; 1031 1032 case Types.NULL : 1033 return "NULL"; 1034 1035 case Types.NUMERIC : 1036 return "NUMERIC"; 1037 1038 case Types.OTHER : 1039 return "OTHER"; 1040 1041 case Types.REAL : 1042 return "REAL"; 1043 1044 case Types.REF : 1045 return "REF"; 1046 1047 case Types.SMALLINT : 1048 return "SMALLINT"; 1049 1050 case Types.STRUCT : 1051 return "STUCT"; 1052 1053 case Types.TIME : 1054 return "TIME"; 1055 1056 case Types.TIMESTAMP : 1057 return "TIMESTAMP"; 1058 1059 case Types.TINYINT : 1060 return "TINYINT"; 1061 1062 case Types.VARBINARY : 1063 return "VARBINARY"; 1064 1065 case Types.VARCHAR : 1066 return "VARCHAR"; 1067 1068 case Types.VARCHAR_IGNORECASE : 1069 return "VARCHAR_IGNORECASE"; 1070 1071 case Types.XML : 1072 return "XML"; 1073 1074 default : 1075 return null; 1076 } 1077 } 1078 1079 1098 public static final int MAX_CHAR_OR_VARCHAR_DISPLAY_SIZE = 1099 MAX_CHAR_OR_VARCHAR_DISPLAY_SIZE(); 1100 1101 private static int MAX_CHAR_OR_VARCHAR_DISPLAY_SIZE() { 1117 1118 try { 1119 return Integer.getInteger( 1120 "hsqldb.max_char_or_varchar_display_size", 32766).intValue(); 1121 } catch (SecurityException e) { 1122 return 32766; 1123 } 1124 } 1125 1126 public static int getMaxDisplaySize(int type) { 1127 1128 switch (type) { 1129 1130 case Types.BINARY : 1131 case Types.LONGVARBINARY : 1132 case Types.LONGVARCHAR : 1133 case Types.OTHER : 1134 case Types.VARBINARY : 1135 case Types.XML : 1136 return Integer.MAX_VALUE; 1138 case Types.CHAR : 1139 case Types.VARCHAR : 1140 return MAX_CHAR_OR_VARCHAR_DISPLAY_SIZE; 1141 1142 case Types.BIGINT : 1144 return 20; 1148 case Types.BOOLEAN : 1149 return 5; 1151 case Types.DATALINK : 1152 return 20004; 1154 case Types.DECIMAL : 1155 case Types.NUMERIC : 1156 return 646456995; 1158 case Types.DATE : 1159 return 10; 1161 case Types.INTEGER : 1162 return 11; 1164 case Types.FLOAT : 1165 case Types.REAL : 1166 case Types.DOUBLE : 1167 return 23; 1169 case Types.TIME : 1170 return 8; 1172 case Types.SMALLINT : 1173 return 6; 1175 case Types.TIMESTAMP : 1176 return 29; 1178 case Types.TINYINT : 1179 return 4; 1181 default : 1182 return 0; } 1184 } 1185 1186 public static boolean isSearchable(int type) { 1187 1188 switch (type) { 1189 1190 case Types.ARRAY : 1191 case Types.BLOB : 1192 case Types.CLOB : 1193 case Types.JAVA_OBJECT : 1194 case Types.STRUCT : 1195 case Types.OTHER : 1196 return false; 1197 1198 default : 1199 return true; 1200 } 1201 } 1202 1203 public static Boolean isCaseSensitive(int type) { 1204 1205 switch (type) { 1206 1207 case Types.ARRAY : 1208 case Types.BLOB : 1209 case Types.CLOB : 1210 case Types.DISTINCT : 1211 case Types.JAVA_OBJECT : 1212 case Types.NULL : 1213 case Types.REF : 1214 case Types.STRUCT : 1215 return null; 1216 1217 case Types.CHAR : 1218 case Types.DATALINK : 1219 case Types.LONGVARCHAR : 1220 case Types.OTHER : 1221 case Types.XML : 1222 return Boolean.TRUE; 1223 1224 case Types.VARCHAR_IGNORECASE : 1225 default : 1226 return Boolean.FALSE; 1227 } 1228 } 1229 1230 public static Boolean isUnsignedAttribute(int type) { 1231 1232 switch (type) { 1233 1234 case Types.BIGINT : 1235 case Types.DECIMAL : 1236 case Types.DOUBLE : 1237 case Types.FLOAT : 1238 case Types.INTEGER : 1239 case Types.NUMERIC : 1240 case Types.REAL : 1241 case Types.SMALLINT : 1242 case Types.TINYINT : 1243 return Boolean.FALSE; 1244 1245 default : 1246 return null; 1247 } 1248 } 1249 1250 public static int getPrecision(int type) { 1251 1252 switch (type) { 1253 1254 case Types.BINARY : 1255 case Types.CHAR : 1256 case Types.LONGVARBINARY : 1257 case Types.LONGVARCHAR : 1258 case Types.OTHER : 1259 case Types.VARBINARY : 1260 case Types.VARCHAR : 1261 case Types.XML : 1262 return Integer.MAX_VALUE; 1263 1264 case Types.BIGINT : 1265 return 19; 1266 1267 case Types.BOOLEAN : 1268 return 1; 1269 1270 case Types.DATALINK : 1271 1272 return 20004; 1274 1275 case Types.DECIMAL : 1276 case Types.NUMERIC : 1277 1278 return 646456993; 1284 1285 case Types.DATE : 1286 case Types.INTEGER : 1287 return 10; 1288 1289 case Types.FLOAT : 1290 case Types.REAL : 1291 case Types.DOUBLE : 1292 return 17; 1293 1294 case Types.TIME : 1295 return 8; 1296 1297 case Types.SMALLINT : 1298 return 5; 1299 1300 case Types.TIMESTAMP : 1301 return 29; 1302 1303 case Types.TINYINT : 1304 return 3; 1305 1306 default : 1307 return 0; 1308 } 1309 } 1310 1311 public static String getColStClsName(int type) { 1312 1313 switch (type) { 1314 1315 case Types.BIGINT : 1316 return "java.lang.Long"; 1317 1318 case Types.BINARY : 1319 case Types.LONGVARBINARY : 1320 case Types.VARBINARY : 1321 1322 return "[B"; 1324 1325 case Types.OTHER : 1326 1327 return "java.lang.Object"; 1329 1330 case Types.BOOLEAN : 1331 return "java.lang.Boolean"; 1332 1333 case Types.CHAR : 1334 case Types.LONGVARCHAR : 1335 case Types.VARCHAR : 1336 case Types.XML : return "java.lang.String"; 1338 1339 case Types.DATALINK : 1340 return "java.net.URL"; 1341 1342 case Types.DATE : 1343 return DateClassName; 1344 1345 case Types.DECIMAL : 1346 case Types.NUMERIC : 1347 return DecimalClassName; 1348 1349 case Types.DOUBLE : 1350 case Types.FLOAT : 1351 case Types.REAL : 1352 return "java.lang.Double"; 1353 1354 case Types.INTEGER : 1355 case Types.SMALLINT : 1356 case Types.TINYINT : 1357 return "java.lang.Integer"; 1358 1359 case Types.TIME : 1360 return TimeClassName; 1361 1362 case Types.TIMESTAMP : 1363 return TimestampClassName; 1364 1365 default : 1366 return null; 1367 } 1368 } 1369} 1370 | Popular Tags |