@@ -228,13 +228,44 @@ private static List<ColumnMeta> toColumnMeta(String[] columns, Map<String, Colum
228
228
return metas ;
229
229
}
230
230
231
+ private static IndexType getIndexType (String type ) {
232
+ if ("BTREE" .equalsIgnoreCase (type )) {
233
+ return IndexType .BTREE ;
234
+ } else if ("HASH" .equalsIgnoreCase (type )) {
235
+ return IndexType .HASH ;
236
+ } else if ("INVERSE" .equalsIgnoreCase (type )) {
237
+ return IndexType .INVERSE ;
238
+ }
239
+ return IndexType .NONE ;
240
+ }
241
+
242
+ private static Relationship getRelationship (String rel ) {
243
+ if ("MANY_TO_MANY" .equalsIgnoreCase (rel )) {
244
+ return Relationship .MANY_TO_MANY ;
245
+ } else if ("ONE_TO_ONE" .equalsIgnoreCase (rel )) {
246
+ return Relationship .ONE_TO_ONE ;
247
+ } else if ("MANY_TO_ONE" .equalsIgnoreCase (rel )) {
248
+ return Relationship .MANY_TO_ONE ;
249
+ } else if ("ONE_TO_MANY" .equalsIgnoreCase (rel )) {
250
+ return Relationship .ONE_TO_MANY ;
251
+ }
252
+
253
+ return Relationship .NONE ;
254
+ }
255
+
256
+ public static DataType jdbcTypeToDataType (int jdbcType ) {
257
+ return getDataType (jdbcTypeToDataTypeString (jdbcType ));
258
+ }
259
+
231
260
private static DataType getDataType (String type ) {
232
261
if ("INT" .equalsIgnoreCase (type ) || "INTEGER" .equalsIgnoreCase (type )) {
233
262
return DataType .IntegerType ;
234
263
} else if ("LONG" .equalsIgnoreCase (type )) {
235
264
return DataType .LongType ;
236
265
} else if ("SHORT" .equalsIgnoreCase (type )) {
237
266
return DataType .ShortType ;
267
+ } else if ("BIGINTEGER" .equalsIgnoreCase (type )) {
268
+ return DataType .BigIntegerType ;
238
269
} else if ("BIGDECIMAL" .equalsIgnoreCase (type )) {
239
270
return DataType .BigDecimalType ;
240
271
} else if ("FLOAT" .equalsIgnoreCase (type )) {
@@ -259,51 +290,29 @@ private static DataType getDataType(String type) {
259
290
return DataType .BlobType ;
260
291
} else if ("BIT" .equalsIgnoreCase (type )) {
261
292
return DataType .BitType ;
293
+ } else {
294
+ throw new IllegalArgumentException ("不支持的类型:" + type );
262
295
}
263
-
264
- return null ;
265
- }
266
-
267
- private static IndexType getIndexType (String type ) {
268
- if ("BTREE" .equalsIgnoreCase (type )) {
269
- return IndexType .BTREE ;
270
- } else if ("HASH" .equalsIgnoreCase (type )) {
271
- return IndexType .HASH ;
272
- } else if ("INVERSE" .equalsIgnoreCase (type )) {
273
- return IndexType .INVERSE ;
274
- }
275
- return IndexType .NONE ;
276
- }
277
-
278
- private static Relationship getRelationship (String rel ) {
279
- if ("MANY_TO_MANY" .equalsIgnoreCase (rel )) {
280
- return Relationship .MANY_TO_MANY ;
281
- } else if ("ONE_TO_ONE" .equalsIgnoreCase (rel )) {
282
- return Relationship .ONE_TO_ONE ;
283
- } else if ("MANY_TO_ONE" .equalsIgnoreCase (rel )) {
284
- return Relationship .MANY_TO_ONE ;
285
- } else if ("ONE_TO_MANY" .equalsIgnoreCase (rel )) {
286
- return Relationship .ONE_TO_MANY ;
287
- }
288
-
289
- return Relationship .NONE ;
290
- }
291
-
292
- public static DataType jdbcTypeToDataType (int jdbcType ) {
293
- return getDataType (jdbcTypeToDataTypeString (jdbcType ));
294
296
}
295
297
296
298
public static String jdbcTypeToDataTypeString (int jdbcType ) {
297
299
String type = null ;
298
300
switch (jdbcType ) {
299
301
case Types .BIGINT :
302
+ // 考虑unsigned
303
+ type = "BIGINTEGER" ;
304
+ break ;
305
+ case Types .NUMERIC :
300
306
case Types .DECIMAL :
301
- type = "LONG " ;
307
+ type = "BIGDECIMAL " ;
302
308
break ;
303
309
case Types .INTEGER :
310
+ // 考虑unsigned
311
+ type = "LONG" ;
312
+ break ;
304
313
case Types .TINYINT :
305
314
case Types .SMALLINT :
306
- case Types . NUMERIC :
315
+ // 考虑unsigned
307
316
type = "INT" ;
308
317
break ;
309
318
case Types .DATE :
@@ -320,6 +329,7 @@ public static String jdbcTypeToDataTypeString(int jdbcType) {
320
329
case Types .DOUBLE :
321
330
type = "DOUBLE" ;
322
331
break ;
332
+ case Types .CHAR :
323
333
case Types .VARCHAR :
324
334
case Types .NCHAR :
325
335
case Types .NVARCHAR :
@@ -333,17 +343,14 @@ public static String jdbcTypeToDataTypeString(int jdbcType) {
333
343
case Types .LONGVARBINARY :
334
344
type = "BYTES" ;
335
345
break ;
336
- case Types .CHAR :
337
- type = "STRING" ;
338
- break ;
339
346
case Types .BLOB :
340
347
type = "BLOB" ;
341
348
break ;
342
349
case Types .BIT :
343
350
type = "BIT" ;
344
351
break ;
345
352
default :
346
- type = null ;
353
+ throw new IllegalArgumentException ( "不支持的类型:" + jdbcType ) ;
347
354
}
348
355
349
356
return type ;
0 commit comments