In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to use JSP to connect to MYSQL database, the article is very detailed, has a certain reference value, interested friends must read it!
You have completed the first step, but I think that is only the most basic. The most urgent thing to know is how to connect with the database. Because, whether it is to make a guestbook or a forum, it will involve the database. In fact, it's all very simple. First of all, make sure that you have installed the MYSQL database, the reason for choosing MYSQL, because it can cross-platform, but mssql or access, do not have. So let's use mysql.
1. Download the JDBC driver of MYSQL (http://mysql.ihostunit.com/Downloads/Contrib/mm.mysql-2.0.4-bin.jar)
2. Copy him to the common/lib directory of tomcat
3. Test whether the connection is normal. Save the following code in the webapps/faq directory from test.jsp to tomcat. :
4. If a blank page appears after running, it is correct.
5. Set up database and table
First, create a table in mysql and insert several pieces of data. The sql code is as follows:
Create database test;-- operation
Use test;-- operation
Create talbe admin (id int (4) auto_increment primary key,name varchar (20));-run
INSERT INTO user (name) VALUES ('gianfeng');-run
Ok, you have created the database test, created the table user, and inserted a record.
6. Display the records in the database:
The code for the following page displays the records in the database:
Study
The above is all the contents of the article "how to connect to a MYSQL database using JSP". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.