import java.sql.*; public class Main { private static final String accessDBURLPrefix = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="; private static final String accessDBURLSuffix = ";DriverID=22;READONLY=false}"; // Initialize the JdbcOdbc Bridge Driver static { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException e) { System.err.println("JdbcOdbc Bridge Driver not found!"); } } public static Connection getAccessDBConnection(String filename) throws SQLException { String databaseURL = accessDBURLPrefix + filename + accessDBURLSuffix; return DriverManager.getConnection(databaseURL, "", ""); } public static void main(String[] args) { try { Connection conn = getAccessDBConnection("User.mdb"); Statement s = conn.createStatement(); catch(Exception ex) { ex.printStackTrace(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)