aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/changes/changes.xml5
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/DataType.java27
2 files changed, 32 insertions, 0 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f273678..e745224 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -4,6 +4,11 @@
<author email="javajedi@users.sf.net">Tim McCune</author>
</properties>
<body>
+ <release version="2.0.8" date="TBD">
+ <action dev="jahlborn" type="fix" system="SourceForge2" issue="113">
+ Add newer sql type to access type mappings if the jvm supports them.
+ </action>
+ </release>
<release version="2.0.7" date="2014-11-22">
<action dev="jahlborn" type="fix" system="SourceForge2" issue="111">
Unicode compression support was not correct for all possibly
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
+ }
+ }
+
}