01-Access Database Basics

Source: Internet
Author: User
Access to modify the database format

File ---> Option ----> default format of the blank database (in general) ---> access2002 -- access2003

The format is set to end with. MDB.

Create a database

Create ----> select the path to save the database --> set the database name ---> Click Create.

Create a data source

Control Panel -- Management Tools -- database files created by data source (ODBC) are used by users on the local machine. Therefore, select "User DSN" and press "add, in the pop-up data source Manager dialog box, select a driver for the data source you want to create. The database file in this article is created using Microsoft Access, so select "Microsoft Access Driver (*. MDB). Press the "finish" button to go to the "ODBC Microsoft Access installation" Page and set "Data Source Name" to "mydatasource ", select the database file "C: \ myfile \ myexample. mdb, and then click OK. This completes the registration of a simple ODBC data source. Of course, in the above steps, you can set different options based on your own needs.

Java connection access

import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;public class Test {public static void main(String args[]) {try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection con = DriverManager.getConnection("jdbc:odbc:mydatasource");System.out.println(con);Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM student"); while (rs.next()) {System.out.println(rs.getString(2));}} catch (Exception ex) {ex.printStackTrace();}}}

Running result

Database Table

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.