Home > Database > Mysql Tutorial > body text

JDBC连接ACCESS数据库的三种方法

WBOY
Release: 2016-06-07 15:43:28
Original
2115 people have browsed it

第一种:使用JDBC的ACCESS驱动程序: 在http://industry.java.sun.com/products/jdbc/drivers下载ACCESS的JDBC驱动程序。 第二种:使用JDBC-ODBC桥访问: Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); conn = DriverManager.getConnection(jdbc:odbc:dbacc

第一种:使用JDBC的ACCESS驱动程序:

在http://industry.java.sun.com/products/jdbc/drivers下载ACCESS的JDBC驱动程序。 

第二种:使用JDBC-ODBC桥访问: 
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
conn = DriverManager.getConnection("jdbc:odbc:dbaccess"); 
第三种:直接访问ACCESS数据库,不使用JDBC-ODBC桥: 
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
String url= "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=access\\dbaccess.mdb"; 
String uname = ""; 
String password = ""; 
Connection conn = DriverManager.getConnection(url, uname, password);
 

注:

access 2007 数据库的驱动文件是专用的 叫AccessDatabaseEngine.exe,在http://download.microsoft.com/download/7/0/3/703ffbcb-dc0c-4e19-b0da-1463960fdcdb/AccessDatabaseEngine.exe可下载

Access 2010 在这下载:http://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe
 
Access2007 或2010连接字符串:
String strurl= "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=F:/Program Files/apache-tomcat-7.0.8/webapps/ROOT/mywebstore/mywebstore.accdb";
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!