Java Connection MS Access database

Source: Internet
Author: User
Tags odbc

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

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.