In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to connect to an access database. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Due to the needs of the work, we need to connect to the access database. It took a long time to sort out the correct connection steps. Now I will share them with you.
1. Install JDK1.7 first. You cannot use JDK1.8, or an exception will be reported.
2. Create an Access file with the suffix (* .mdb), create a table, the table name must be an English name, add a field, which is also an English name.
3. Locate the control panel under (Windows10), find the management tool, and enter the data source (as shown in the following figure).
4. Click the fourth item, add a data source, and select Access Driver.
5. Bind the data source to the Access file you created.
6. Add running code
Import java. Sql.*;public class Database {public static void main (String [] args) {try {Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:Database"; / / Database is the name of the data source Connection con = DriverManager.getConnection (url, ",") that you just added. / / account, password is empty Statement sta = con.createStatement (); ResultSet rst = sta.executeQuery ("select * from Student") by default in advanced options; / / demoTable is a table name in access database if (rst.next ()) {while (rst.next ()) {System.out.println (rst.getString ("ID")) / / ID is the field name} catch (ClassNotFoundException e) {e.printStackTrace ();} catch (SQLException e) {e.printStackTrace ();}
7. Running effect (each person sets up a different database, and the running effect is also different)
Thank you for reading! This is the end of this article on "how to connect to the access database". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.