0

I was tasked to use an access database as the method of permanent storage in a Netbeans java project. It was suggested that we use Ucanaccess which I tried, but I was unable to establish a connection.

I have tried the following tutorials:

  1. http://wiki.netbeans.org/ConnectingToMsAccessDB
  2. https://www.tutorialsfield.com/how-to-connect-ms-access-database-in-java/
  3. https://www.youtube.com/watch?v=DhuafZrlWq4
  4. https://www.youtube.com/watch?v=RFr1Gf78l2Y

Non of which worked. When I tried to do the control panel connection under ODBC data sources under System DSN, nothing showed up. (I tried both the 32bit and 64bit versions). When I contacted my teacher she told me that connections aren't made in windows anymore, and that we code the "bridge" in java.

This is how the System DSN looks when I click add

Can anyone please explain to me how to do this?

This is my current code:

import java.sql.Connection;
import java.sql.DriverManager;

public class access
{
    public static void main(String[] args)
    {
            try{
              Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");//Loading Driver
              Connection connection= DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\marco\\Desktop\\stocktracker.accdb");//Establishing Connection
              System.out.println("Connected Successfully");

          }catch(Exception e){
              System.out.println("Error in connection");

          }
    }

} 

This is what the exception looks like that I get when running the code

Hope to hear from you guys soon.

Gord Thompson
  • 98,607
  • 26
  • 164
  • 342
Markun
  • 1
  • 1
  • Have you tried following the instructions in [this answer](https://stackoverflow.com/a/21955257/2144390)? – Gord Thompson Apr 05 '20 at 13:08
  • 1
    Thank you Gord Tompson. I just followed that answer and it worked. Thanks for linking me to it! Connection successful – Markun Apr 06 '20 at 10:25

0 Answers0