用户java访问access2007 不需要配置数据源!
public static void main(String[] args) throws SQLException, UnsupportedEncodingException { // --Access 数据库路径 String dbpath = "C:\\Users\\hlu\\Desktop\\hua\\hua_dic_db.mdb"; //路劲最好不要出现中文,本人测试过程中中文报错! // --连接字符串 String url = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + dbpath; Properties properties = new Properties() ; properties.setProperty("charSet", "gbk") ; //这里设置是为了防止查询的时候出现乱码 Connection conn = null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } conn = DriverManager.getConnection(url,properties); Statement statement = conn.createStatement(); ResultSet rs = statement.executeQuery("select * from xhzd_surnfu"); while(rs.next()){ System.out.println(new String(rs.getString(1).getBytes(),"UTF-8")) ; //1.查询的时候下标是从1开始的;2. 注意转编码 } conn.close(); }