There are two ways to connect to MS Access in Java:
1.jdbc-odbc
Java connection Access can use the MS-brought management tool--data source (ODBC) settings to establish a connection so that you do not need to import the jar. However, there is no aspect to be set on each machine that the program deploys. So I won't use it now.
2.JDBC
Java can also connect to other databases like MS Access, import the corresponding jar package for the database to connect.
Java Access JDBC jar package: Access_jdbc30.jar
For a specific connection, refer to the following code:
1 Try {2 ///Load Drive jar3Class.forName ("Com.hxtt.sql.access.AccessDriver"). newinstance (); 4 //Specify the location of the Access database file5String URL ="Jdbc:access:///c:/a/db.mdb";6 //Establish a connection7conn = drivermanager.getconnection (URL,"username","Password");8}Catch(Exception e) {9 e.printstacktrace ();Ten}
Other queries are the same as other databases, such as: http://www.cnblogs.com/xudong-bupt/p/3741703.html
3. Description:
Now basically do not use ODBC to connect to the database, and basically do not use access, like I took out the old before the program today to run a look is access, or use JDBC Bar.
Transferred from: http://blog.chinaunix.net/uid-26063552-id-1751504.html