0
votes

Is there a way to find version number of MS Access using java code. I am using jdbc-odbc bridge to connect with MS Access.

My usecase is to load mdb and accdb driver using JDBC DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft Access Driver(.mdb,.accdb);}DBQ=filename")

If i use access 2003 or previous version, accdb driver will not be installed. So, while loading it throws exception. What is the way to resolve it.

Thanks in advance.

Regards, Ganesan

2
Please edit your question to clarify whether you want: (1) the version of the Microsoft Access program itself (if any) that is installed on the machine, (2) the version of the ACE/Jet database engine that is accessing the database file, or (3) the version (file format) of the database file being accessed.Gord Thompson
Have you tried catching any errors that occur when attempting to use the ACE driver (*.mdb, *.accdb) and then just try to use the Jet driver (*.mdb) instead?Gord Thompson

2 Answers

0
votes

From the java.sql.Connection you have getMetaData() to get the DatabaseMetaData. Several methods are available here (eg. getDatabaseMajorVersion()) to get version information, if the Driver implement this info.

0
votes

To use the driver, it must be installed and registered. That you can check:

Enumeration<Driver> driverlist = DriverManager.getDrivers();
while(driverlist.hasMoreElements()) {
   System.out.println(driverlist.nextElement().getClass());
}

https://www.tutorialspoint.com/how-to-get-the-list-of-all-drivers-registered-with-the-drivermanager-using-jdbc