Create a connection to MS Access database : Access « Database « Java Tutorial






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

public class Main {
  // private static final String URL = "jdbc:odbc:TestDB";

  private static final String USERNAME = "admin";

  private static final String PASSWORD = "welcome";

  private static final String DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";

  private static final String URL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Database\\testdb.mdb;}";

  public static void main(String[] args) throws Exception {

    Class.forName(DRIVER);
    Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);

    connection.close();
  }
}








20.38.Access
20.38.1.Create a connection to MS Access database
20.38.2.Using DSN-less connection