Eclipse uses ODBC to configure data sources to connect to the Access Database

Source: Internet
Author: User

I have been using MySQL databases all the time before. Today I tried Microsoft's access database. Compared with Oracle, sqlserver, MySQL, and other databases, access database is a relatively small but simple database.

Before connecting to a database using ODBC, you must use the Windows ODBC data source Manager to configure the database as an ODBC data source.

The configuration process is as follows:

(1) In "Management Tools" on the "control panel", double-click "Data Source" and click "add" in the "data source Manager" dialog box.

(2) In the "Create a new data source" dialog box, select "Microsoft Access Driver (*. mdb)" as the data source driver, and click "finish.

(3) In the "ODBC Microsoft Access installation" dialog box, enter the "Data Source Name" value as student_access. Click "select" to select the path of the database file.

The data source configuration is complete. You can return to the "ODBC data source Manager" dialog box. The user data source list box on the user DSN tab shows the student_access data source. If yes, the configuration is successful, of course, you can also modify it and click "Configure.

Database connection process:

Import java. SQL. connection;
Import java. SQL. drivermanager;
Import java. SQL. sqlexception;


Public class testaccess {

/**
* @ Param ARGs
* @ Throws classnotfoundexception
* @ Throws sqlexception
*/
Public static void main (string [] ARGs) throws classnotfoundexception, sqlexception {
// Todo auto-generated method stub
Class. forname ("Sun. JDBC. ODBC. jdbcodbcdriver ");
// Connect to the database
Connection con = drivermanager. getconnection ("JDBC: ODBC: student_access ");
If (con! = NULL ){
System. Out. println ("success ......... ");
}
}

}

  

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.