Java Connection MS Access database
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:
Copy Code
1 try {
2///load Drive jar
3 Class.forName ("Com.hxtt.sql.access.AccessDriver"). newinstance ();
4//Specify the location of the Access database files
5 String url = "Jdbc:access:///c:/a/db.mdb";
6//Establish connection
7 conn = drivermanager.getconnection (URL, "username", "password");
8} catch (Exception e) {
9 E.printstacktrace ();
10}
Copy Code
Other queries are the same as other databases, such as: http://www.cnblogs.com/xudong-bupt/p/3741703.html
3. Description:
Two ways to connect to the database code is not the same, this should be noted.
Note: The article from the Asahi East Blog
Java Connection MS Access database