aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2014-11-26 17:14:36 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2014-11-26 17:14:36 +0000
commitbae32bb3b12b3857b7e7f2c8e8df7bc247eddb64 (patch)
tree840e273e8314933d03cd6bfccb028c4089132a15 /src/main
parentba9f98969fcb1d47734b94cfb941d46d126e20a5 (diff)
downloadjackcess-bae32bb3b12b3857b7e7f2c8e8df7bc247eddb64.tar.gz
jackcess-bae32bb3b12b3857b7e7f2c8e8df7bc247eddb64.zip
Add newer sql type to access type mappings if the jvm supports them. fixes #113
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@899 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/DataType.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/DataType.java b/src/main/java/com/healthmarketscience/jackcess/DataType.java
index e115cdf..ffd5bf4 100644
--- a/src/main/java/com/healthmarketscience/jackcess/DataType.java
+++ b/src/main/java/com/healthmarketscience/jackcess/DataType.java
@@ -200,6 +200,14 @@ public enum DataType {
ALT_SQL_TYPES.put(Types.VARCHAR, MEMO);
ALT_SQL_TYPES.put(Types.VARBINARY, OLE);
ALT_SQL_TYPES.put(Types.BINARY, OLE);
+
+ // add newer sql types if available in this jvm
+ addNewSqlType("NCHAR", TEXT, null);
+ addNewSqlType("NVARCHAR", TEXT, MEMO);
+ addNewSqlType("LONGNVARCHAR", MEMO, null);
+ addNewSqlType("NCLOB", MEMO, null);
+ addNewSqlType("TIME_WITH_TIMEZONE", SHORT_DATE_TIME, null);
+ addNewSqlType("TIMESTAMP_WITH_TIMEZONE", SHORT_DATE_TIME, null);
}
private static Map<Byte, DataType> DATA_TYPES = new HashMap<Byte, DataType>();
@@ -481,4 +489,23 @@ public enum DataType {
return rtn;
}
+ /**
+ * Adds mappings for a sql type which was added after jdk 1.5 (using
+ * reflection).
+ */
+ private static void addNewSqlType(String typeName, DataType type,
+ DataType altType)
+ {
+ try {
+ java.lang.reflect.Field sqlTypeField = Types.class.getField(typeName);
+ Integer value = (Integer)sqlTypeField.get(null);
+ SQL_TYPES.put(value, type);
+ if(altType != null) {
+ ALT_SQL_TYPES.put(value, altType);
+ }
+ } catch(Exception ignored) {
+ // must not be available
+ }
+ }
+
}