Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetDriver.java.in @ 714:ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 05 Jan 2023 00:01:06 +0100 (2023-01-04) |
parents | bdeabbd46ec6 |
children | aeb268156580 |
comparison
equal
deleted
inserted
replaced
713:c3c424a90a42 | 714:ad7b08ef7745 |
---|---|
388 // when it is a new type (not yet added in the above typeMap) or | 388 // when it is a new type (not yet added in the above typeMap) or |
389 // when type name is: any or geometry or geometrya or mbr or ptr or table. | 389 // when type name is: any or geometry or geometrya or mbr or ptr or table. |
390 return Types.OTHER; | 390 return Types.OTHER; |
391 } | 391 } |
392 | 392 |
393 /** | |
394 * Returns the Class object for a given java.sql.Types value. | |
395 * | |
396 * @param type a value from java.sql.Types | |
397 * @return a Class object from which an instance would be returned | |
398 */ | |
399 static final Class<?> getClassForType(final int type) { | |
400 /** | |
401 * This switch returns the types as objects according to table B-3 from | |
402 * Oracle's JDBC specification 4.1 | |
403 */ | |
404 switch(type) { | |
405 case Types.CHAR: | |
406 case Types.VARCHAR: | |
407 case Types.LONGVARCHAR: | |
408 return String.class; | |
409 case Types.NUMERIC: | |
410 case Types.DECIMAL: | |
411 return java.math.BigDecimal.class; | |
412 case Types.BOOLEAN: | |
413 return Boolean.class; | |
414 case Types.TINYINT: | |
415 case Types.SMALLINT: | |
416 return Short.class; | |
417 case Types.INTEGER: | |
418 return Integer.class; | |
419 case Types.BIGINT: | |
420 return Long.class; | |
421 case Types.REAL: | |
422 return Float.class; | |
423 case Types.FLOAT: | |
424 case Types.DOUBLE: | |
425 return Double.class; | |
426 case Types.BINARY: // MonetDB currently does not support these | |
427 case Types.VARBINARY: // see treat_blob_as_binary property | |
428 case Types.LONGVARBINARY: | |
429 return byte[].class; | |
430 case Types.DATE: | |
431 return java.sql.Date.class; | |
432 case Types.TIME: | |
433 case Types.TIME_WITH_TIMEZONE: | |
434 return java.sql.Time.class; | |
435 case Types.TIMESTAMP: | |
436 case Types.TIMESTAMP_WITH_TIMEZONE: | |
437 return java.sql.Timestamp.class; | |
438 case Types.CLOB: | |
439 return java.sql.Clob.class; | |
440 case Types.BLOB: | |
441 return java.sql.Blob.class; | |
442 | |
443 // all the rest are currently not implemented and used | |
444 default: | |
445 return String.class; | |
446 } | |
447 } | |
448 | |
393 private static String TypeMapppingSQL; // cache to optimise getSQLTypeMap() | 449 private static String TypeMapppingSQL; // cache to optimise getSQLTypeMap() |
394 /** | 450 /** |
395 * Returns a String usable in an SQL statement to map the server types | 451 * Returns a String usable in an SQL statement to map the server types |
396 * to values of java.sql.Types using the global static type map. | 452 * to values of java.sql.Types using the global static type map. |
397 * The returned string will be a SQL CASE x statement where the x is | 453 * The returned string will be a SQL CASE x statement where the x is |