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 ......... ");
}
}
}