Java connect to two ways of MS Access:
1.jdbc-ODBC
Java connection ACCESS can use MS to set up the management tools-> data source (ODBC) settings to establish a connection, so that no JAR is required. However, in this way, each machine deployment must be set up. So I won't use it now.
2.jdbc
Java can also connect MS Access like connecting other databases, and import the corresponding jar package of the database for connection.
Copy code code as follows:
Java Access JDBC JAR Pack: Access_JDBC30.JAR
Specific connection, refer to the following code:
Copy code code as follows:
try {
/// Load the driver 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";
// Create a connection
conn = DriverManager.getConnection (url, "username", "password");
} Catch (Exception E) {{
e.printstacktrace ();
}
Other queries are the same as other databases, such as: //www.vevb.com/article/68620.htm
3. Explanation:
Now I do n’t use ODBC to connect the database, and I do n’t use Access. Like I took out the procedures for the old before, I want to run and see if it ’s ACCESS, or use JDBC.