0

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

Ganesan G
  • 59
  • 7
  • 1
    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 Aug 05 '13 at 16:04
  • 1
    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 Aug 12 '13 at 14:52

2 Answers2

0

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.

PeterMmm
  • 24,152
  • 13
  • 73
  • 111
  • Nice idea, but unfortunately `getDatabaseMajorVersion()` throws an "UnsupportedOperationException" when run against a connection to an Access database file. – Gord Thompson Aug 05 '13 at 16:00
0

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

david
  • 2,435
  • 1
  • 21
  • 33