SamerPTUK
SamerPTUK

Reputation: 1

ODBC Driver Manager not found .. Connect MSAccess with Java?

This problem appears to me when I run the program https://i.sstatic.net/3uCDX.png

From Control Panel > Administrative Tools > ODBC Data Source (64-bit) User DSN not contain MSAccess

not possible to add Access driver .. http://im74.gulfup.com/aUnu7p.png

Please How can Solve this problem and thanks you ..

Here is my code.

public class Main 
{
    private static final String MyDataBase = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBO=C:\\Users\\samer\\workspace\\DS2\\DB\\DS2.mdb;";      
    private static Connection conn = null;
    private static Statement stat = null ;

    public Main() 
    {
        try 
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            conn = DriverManager.getConnection(MyDataBase);
            stat = conn.createStatement();
            String sql = "insert into Employee values (1001,'10011001')";
            stat.execute(sql);    
            JOptionPane.showMessageDialog(null , "correct insert");
        } 
        catch (SQLException e1) 
        {
            e1.printStackTrace();
            JOptionPane.showMessageDialog(null , "Sorry1 ,  Try again !!");
        } catch (ClassNotFoundException e2) 
        {
            e2.printStackTrace();
            JOptionPane.showMessageDialog(null , "Sorry2 ,  Try again !!");
        }
    }

    public static void main(String[] args) 
    {
        new Main();
    }
}

Upvotes: 0

Views: 126

Answers (1)

EdH
EdH

Reputation: 5003

I believe that driver is going away (it is not in Java 8).

I've been using a JDBC solution called UCanAccess within Java, and it's been working quite well for me.

http://ucanaccess.sourceforge.net/site.html

Upvotes: 1

Related Questions