giovedì 13 ottobre 2016

Tip: Loading Selected Tables

When connecting to an Access database, UCanAccess copies all of the data from each Access table into a corresponding table in the HSQLDB backing database. So, for example, if we connect directly to the “Northwind.accdb” database then UCanAccess will copy all twenty (20) tables:

If we only need to work with a subset of those tables then we can shorten the load time and reduce memory consumption of our Java application by first creating a “linking database” that only includes the tables of interest.

Say for example that we only need to work with the [Customers], [Orders], and [Order Details] tables. If we create a new Access database named “LinkToNorthwind.accdb” and then create table links into “Northwind.accdb” …

… for just those three tables …

… then when we have UCanAccess connect to “LinkToNorthwind.accdb” it will only populate the HSQLDB backing database with the three tables we need to use …

… and ignore the other seventeen (17) tables that are of no interest to us.

Bonus Tip: If you want to dynamically achieve the same result from your Java application without first having to manually create a separate "linking database", check out the following code:

Nessun commento:

Posta un commento