Two ways for Java to connect to MS Access:
1.jdbc-odbc
Java connection Access can establish a connection using MS's own administrative tools--> data Source (ODBC) settings so that you do not need to import jars. However, there are no aspects to be set on each machine where the program is deployed. So it's not going to work now.
2.JDBC
Java can also connect to Ms Access as you connect to other databases, import the appropriate jar packages for your database, and connect.
Copy Code code as follows:
Java Access JDBC jar package: Access_jdbc30.jar
For specific connections, refer to the following code:
Copy Code code as follows:
try {
Load Drive jar
Class.forName ("Com.hxtt.sql.access.AccessDriver"). newinstance ();
Specify the location of the Access database file
String url = "Jdbc:access:///c:/a/db.mdb";
Establish a connection
conn = drivermanager.getconnection (URL, "username", "password");
catch (Exception e) {
E.printstacktrace ();
}
Other queries are the same as other databases, such as: http://www.jb51.net/article/68620.htm
3. Description:
Now basically do not use the ODBC way to connect the database, also basically do not use access, like I took out the old program today want to run a run a look is access, or use JDBC Bar.