Java Connection MS Access database

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.