0

I am a student and we are working on a project in Access database but in windows.
When I go back home I tried to run and edit the project but it didn't work. Notice that I don't have Access installed on my mac.
My questions:
1- do I have to install Access on my mac?
2- If not why do I have this error?

package DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class empQueries {
    
    private static String URL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=/Users/Home/Desktop/My Tools/DB + proj/HR.mdb";
    private static String userName =""; //Access no neeed for username or password
    private static String Password ="";
    
    private Connection Con = null;
    private PreparedStatement selectAllStatement = null;
    private PreparedStatement insertNewPerson = null;
    private PreparedStatement updatePerson = null;
    private PreparedStatement deletePerson = null;
    
    public empQueries()
    {
        try {
         
            Con = DriverManager.getConnection(URL);
            System.out.print("Success");
        } catch (SQLException ex) {
            System.out.print("not Success");;
        }
    }
    public static void main(String [] args)
    {
        empQueries Test = new empQueries();
    }
    
}

Thanks.

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by Ezzaral
0

> do I have to install Access on my mac
You need the ODBC driver for Access. There are third-party vendors that sell them, though I'm not sure if there are any free options available to you.

Maybe you could switch to JavaDB or H2 instead?

Edited by Ezzaral: n/a

0

Well as my knowledge Java has Access drivers installed already, or this is for windows only? Or I'm wrong?

0

No, Java has no drivers for Access. You are currently using the JDBC/ODBC bridge driver, which allows JDBC connection through a separately installed ODBC driver.

0

Read the docs or forums I suppose. I have no idea if that will allow you to use the Access ODBC driver. Maybe their FAQ will help?

I'll just reiterate my suggestion to use a different database if you want to work on Mac.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.