From 6deaa095c7c77dfebf797fe4e4e1ff086cf932d9 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Wed, 25 Nov 2015 21:34:12 +0000 Subject: [PATCH] Add FileFormat.GENERIC_JET4 in order to support getting the file format for jet4 databases with no AccessVersion property (e.g. those created programmatically using ADOX). fixes issue #129 git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@970 f203690c-595d-4dc9-a70b-905162fa7fd2 --- src/changes/changes.xml | 5 +++++ .../healthmarketscience/jackcess/Database.java | 9 +++++++++ .../jackcess/impl/DatabaseImpl.java | 7 +++++++ .../jackcess/impl/JetFormat.java | 1 + src/test/data/V2007/complexDataTestV2007.accdb | Bin src/test/data/V2007/linkerTestV2007.accdb | Bin src/test/data/V2007/oldDatesV2007.accdb | Bin src/test/data/V2007/testOleV2007.accdb | Bin src/test/data/V2010/complexDataTestV2010.accdb | Bin src/test/data/adox_jet4.mdb | Bin 0 -> 65536 bytes src/test/data/linkeeTest.accdb | Bin .../jackcess/impl/JetFormatTest.java | 11 +++++++++++ 12 files changed, 33 insertions(+) mode change 100755 => 100644 src/test/data/V2007/complexDataTestV2007.accdb mode change 100755 => 100644 src/test/data/V2007/linkerTestV2007.accdb mode change 100755 => 100644 src/test/data/V2007/oldDatesV2007.accdb mode change 100755 => 100644 src/test/data/V2007/testOleV2007.accdb mode change 100755 => 100644 src/test/data/V2010/complexDataTestV2010.accdb create mode 100644 src/test/data/adox_jet4.mdb mode change 100755 => 100644 src/test/data/linkeeTest.accdb diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2350392..c62159a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -9,6 +9,11 @@ Throw a prettier exception when maxing out the row size during row creation. + + Add FileFormat.GENERIC_JET4 in order to support getting the file + format for jet4 databases with no AccessVersion property (e.g. those + created programmatically using ADOX). + Add some utility methods (DatabaseBuilder.createDateFormat and DatabaseBuilder.toCompatibleCalendar) for handling Dates in an Access diff --git a/src/main/java/com/healthmarketscience/jackcess/Database.java b/src/main/java/com/healthmarketscience/jackcess/Database.java index 1e6d6cf..48273ef 100644 --- a/src/main/java/com/healthmarketscience/jackcess/Database.java +++ b/src/main/java/com/healthmarketscience/jackcess/Database.java @@ -130,11 +130,20 @@ public interface Database extends Iterable, Closeable, Flushable */ public enum FileFormat { + /** A database which was created by MS Access 97 */ V1997(".mdb"), + /** A database which was most likely created programmatically (e.g. using + windows ADOX) */ + GENERIC_JET4(".mdb"), + /** A database which was created by MS Access 2000 */ V2000(".mdb"), + /** A database which was created by MS Access 2002/2003 */ V2003(".mdb"), + /** A database which was created by MS Access 2007 */ V2007(".accdb"), + /** A database which was created by MS Access 2010+ */ V2010(".accdb"), + /** A database which was created by MS Money */ MSISAM(".mny"); private final String _ext; diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java index 1984dc3..490e75f 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java @@ -110,6 +110,7 @@ public class DatabaseImpl implements Database static { addFileFormatDetails(FileFormat.V1997, null, JetFormat.VERSION_3); + addFileFormatDetails(FileFormat.GENERIC_JET4, null, JetFormat.VERSION_4); addFileFormatDetails(FileFormat.V2000, "empty", JetFormat.VERSION_4); addFileFormatDetails(FileFormat.V2003, "empty2003", JetFormat.VERSION_4); addFileFormatDetails(FileFormat.V2007, "empty2007", JetFormat.VERSION_12); @@ -202,6 +203,7 @@ public class DatabaseImpl implements Database /** Name of the system object that is the parent of all databases */ private static final String SYSTEM_OBJECT_NAME_DATABASES = "Databases"; /** Name of the system object that is the parent of all relationships */ + @SuppressWarnings("unused") private static final String SYSTEM_OBJECT_NAME_RELATIONSHIPS = "Relationships"; /** Name of the table that contains system access control entries */ @@ -739,6 +741,11 @@ public class DatabaseImpl implements Database // need to check the "AccessVersion" property String accessVersion = (String)getDatabaseProperties().getValue( PropertyMap.ACCESS_VERSION_PROP); + + if(isBlank(accessVersion)) { + // no access version, fall back to "generic" + accessVersion = null; + } _fileFormat = possibleFileFormats.get(accessVersion); diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java b/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java index 115dd94..eed8832 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java @@ -127,6 +127,7 @@ public abstract class JetFormat { static { POSSIBLE_VERSION_4.put(ACCESS_VERSION_2000, Database.FileFormat.V2000); POSSIBLE_VERSION_4.put(ACCESS_VERSION_2003, Database.FileFormat.V2003); + POSSIBLE_VERSION_4.put(null, Database.FileFormat.GENERIC_JET4); } } diff --git a/src/test/data/V2007/complexDataTestV2007.accdb b/src/test/data/V2007/complexDataTestV2007.accdb old mode 100755 new mode 100644 diff --git a/src/test/data/V2007/linkerTestV2007.accdb b/src/test/data/V2007/linkerTestV2007.accdb old mode 100755 new mode 100644 diff --git a/src/test/data/V2007/oldDatesV2007.accdb b/src/test/data/V2007/oldDatesV2007.accdb old mode 100755 new mode 100644 diff --git a/src/test/data/V2007/testOleV2007.accdb b/src/test/data/V2007/testOleV2007.accdb old mode 100755 new mode 100644 diff --git a/src/test/data/V2010/complexDataTestV2010.accdb b/src/test/data/V2010/complexDataTestV2010.accdb old mode 100755 new mode 100644 diff --git a/src/test/data/adox_jet4.mdb b/src/test/data/adox_jet4.mdb new file mode 100644 index 0000000000000000000000000000000000000000..7fbdb1b148c10099352cc9790f5c16262f1a7a27 GIT binary patch literal 65536 zcmeI5e`sB28ONVVcD1uXh7;MkwvIWbXxe7Qg``=UmJtTEN$yRPrb)_e zTGwruOdae8%z{id=_nIKhJp^E%64{q4|&FqVxntt`n{jU`t{^SjBJp62W+cW>Y19y+d2bO^2lzjE~wWQ>y{%Jp`^GX6FKmsH{0wh2JBtQZr zKmsH{0wl1O2vk>8QqG@qx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