Thursday, 7 December 2017

Connecting Netbeans to MS Access - Resolved Problems

In this blog, I am going to address some of the typical problems encountered by  programmers who try to connect Netbeans to the MS Access Database.

Since I traveled to Hungary for my Research, I have not responded to your comments for some time, but now I'm fully back to work since I have stabilized a bit in Budapest after suffering some jet lag.

Take a look at the comments below

From the list of comments, you could see that the key question is:
  • Missing JDBC-ODBC Bridge in Netbeans
  • JDBC-ODBC driver not available in Netbeans 

Other issues include:
  • There is nothing under databases in Java - Parth Mistry 
  • Can you explain how to access MS Access using UcanAccess - Ahmed Moh
  • Unable to create the Datasource
  • Could you make a video on how to Add, Edit, Delete and Modify Data - Uday Kumah

Lest start from the first one - Missing JDBC-ODBC Driver

Cause of the Problem
The problem arises because Java stopped providing the JDBC-ODBC bridge as from Java 8. This means that  is you are using Netbeans 8.x, then you would not be able to access the driver.

Solution 1 (recommended)
Install Netbeans 7.x. This is the easiest way to resolve this issue. For the tutorials we are working with and for fairly large project, you could use Netbeans 7.x. Remember,  that means you would also install jdk-7 which you can get from here.
Note that you could still recieve updates and new plugins for Netbeans 7.x.
For me, I have both installations in my system and both are working perfectly.

Solution 2 (Buy a Connector)
You could actually buy an JDBC-ODBC connector for Netbeans 8.x. I have tried to check if i could find a free one but I have not found. There is one from EasySoft you can buy or try out for two weeks. You can find it here.

Unable to Create Datasource in Windows - MS Access Driver Not found
If you go to Administrative Tools > ODBC Data sources and click on the System DSN tab. You could create a new datasource by clicking the Add button. This would display the window below:
You can see a list of drivers.
However, if in your system, it shows blank. Then it means that there is a mismatch between the MS office  and your operating system. One is 32bit and the other is 64 or vice versa.

Go to the windows folder in your drive C and locate the two folders:
  • System32
  • SysWOW64
Inside each, there is odbcad32. You can open it and use it to create your datasource. If it works, then you can add a shortcut to your desktop so you can always use it

I hope this brief explanation solves the issues. If there are any more issues, you can leave a comment below.
I made this easy tutorial: How to Build a Calculator in Java Using Netbeans. You can easily follow it.

Thanks and have a nice day.