Several ways of connecting JDBC to access database

For example, there are the following access database student, table basic, and 6 records. Now their data is displayed in JSP in several ways. As shown in the figure:

For several ways of connecting to access database, they are basically based on jdbc-odbc. Of course, there are also pure JDBC driven ways. I won't say it here for the time being. For these methods, except for the differences in obtaining connections, the other codes are the same. So here are several ways to get the connection, and then use the complete code to display it.

Mode 1: direct connection through jdbc-odbc bridge:

1. For this method, first establish ODBC data source. My system is win7 system, so select "control panel - management tools - data source (ODBC)" and open the data source manager, as shown in the figure:

2. In the system DSN tab, click Add to open the create data source dialog box, and select the Microsoft Access driver (*. MDB) of the access database, as shown in the figure:

3. Click Finish to open the following dialog box. Enter the name of the data source "jdbc-odbc" in the data source name, click Select, select the database to operate "student. MDB", and click OK to complete the data source configuration. As shown in the figure:

4. After the data source is configured, you can write the code to obtain the connection, as shown below:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>