Before connecting to your Access database from Java, you must have successfully installed the Easysoft JDBC-Access Gateway.
For Easysoft JDBC-Access Gateway installation instructions, see Installation.
To register the Easysoft JDBC-Access Gateway JDBC driver, your Java application must specify the class easysoft.sql.esMdbDriver. For example:
Class.forName("easysoft.sql.esMdbDriver");
When the Easysoft JDBC-Access Gateway JDBC driver is registered, you can establish a connection by using a connection URL and the getConnection method of the DriverManagerclass. For example:
String connectionUrl = "jdbc:easysoft:mdb?DBQ=C:/Users/Public/Northwind.mdb";
Connection con = DriverManager.getConnection(connectionUrl);
To establish a connection with the Easysoft JDBC-Access Gateway, use a connection URL of the form:
jdbc:easysoft:mdb?DBQ=<path>[;<odbc-driver-attribute>=<value>]
<path> is the path to the Access database (.mdb).
<odbc-driver-attribute> is an Access ODBC driver attribute.
You can retrieve the available Access ODBC driver attributes along with a description for each attribute by using the getPropertyInfo method of the Driver class. For example:
public static void driverProperties() {
// Replace the DBQ value with the path to your Access database.
String connectionUrl = "jdbc:easysoft:mdb?" +
"DBQ=C:/Northwind/BlankII.mdb";
DriverPropertyInfo props[] = null;
Class.forName("easysoft.sql.esMdbDriver");
driver = DriverManager.getDriver(connectionUrl);
props = driver.getPropertyInfo (connectionUrl, new Properties());
System.out.println ("JDBC URL Attributes");
for (int i = 0; i < props.length; i++) {
System.out.print ("\t" + props[i].name);
System.out.print (props[i].value);
System.out.println (props[i].description +".");
Opens an Access database and enables Jet 4.0 features:
jdbc:easysoft:mdb?DBQ=C:/Users/Public/Northwind.mdb;ExtendedAnsiSQL=True
Opens an an Access database that is stored in a shared folder:
jdbc:easysoft:mdb?DBQ=//mymachine/myshare/Sales.accdb
Opens a password-protected Access database from a mapped network drive: