Currently I have one application in which I am able to access .mdb or .accdb file with JdbcOdbcDriver to append some data.
Class.forName(\"sun.jdbc.odbc.Jdb
Now that the JDBC-ODBC Bridge has been removed from Java (as of Java 8), future readers might be interested in UCanAccess, a free and open-source pure Java JDBC driver for Access databases. UCanAccess includes a newdatabaseversion connection parameter that will create the Access .accdb or .mdb file if it does not already exist.
Sample code:
String dbFileSpec = "C:/Users/Gord/Desktop/myDb.accdb";
try (Connection conn = DriverManager.getConnection(
"jdbc:ucanaccess://" + dbFileSpec +
";newdatabaseversion=V2010")) {
DatabaseMetaData dmd = conn.getMetaData();
try (ResultSet rs = dmd.getTables(null, null, "Clients", new String[] { "TABLE" })) {
if (rs.next()) {
System.out.println("Table [Clients] already exists.");
} else {
System.out.println("Table [Clients] does not exist.");
try (Statement s = conn.createStatement()) {
s.executeUpdate("CREATE TABLE Clients (ID COUNTER PRIMARY KEY, LastName TEXT(100))");
System.out.println("Table [Clients] created.");
}
}
}
conn.close();
}
For details on how to set up UCanAccess see
Manipulating an Access database from Java without ODBC