How to get JDBC Connection to MS-Access Database in Java?

Below code shows how to get JDBC Connection to MS Access database –

 * Created on 05-2011 Copyright(c) All Rights Reserved.
package com.kodehelp.javasql;

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

 * Created by
 * Date: 5/9/11
public class GetMSAccessConnection {

    private static final String USERNAME = "USERNAME";
    private static final String PASSWORD = "PASSWORD";
    private static final String DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
    private static final String URL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Database\\testdb.mdb;}";
    public static void main(String args[]) throws ClassNotFoundException, SQLException {
        Connection conn = null;
            Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
        }catch (ClassNotFoundException cnfEx){
            throw cnfEx;
        }catch (SQLException sqlEx){
            throw sqlEx;


one comment

  1. Jgdev says:

    So good :), how to download JDBC jar file?

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.