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:
- http://wiki.netbeans.org/ConnectingToMsAccessDB
- https://www.tutorialsfield.com/how-to-connect-ms-access-database-in-java/
- https://www.youtube.com/watch?v=DhuafZrlWq4
- 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.