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