Java examples for java.sql:ODBC
get Access Database Connection via Jdbc Odbc Bridge
//package com.java2s; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Main { public static void main(String[] argv) throws Exception { String path = "java2s.com"; System.out.println(getAccessConn(path)); }// w ww . j a v a2 s .com public static Connection getAccessConn(String path) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=" + path; return DriverManager.getConnection(url, "", ""); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } catch (SQLException ex) { ex.printStackTrace(); } return null; } }